I've come across some code in a Rails app in the form of
ThirdPartyLibrary::Foo.class_eval do
def bar?
@bar_field == 'true'
end
end
and I'm wondering why they didn't just do
class ThirdPartyLibrary::Foo
def bar?
@bar_field == 'true'
end
end
Are there any advantages in using class_eval
when there isn't anything you want to pass in to the new code?