ColinDKelley escreveu: > ... > For example, this: > > state = params[:state] unless params[:state].blank? > country = params[:country] unless params[:country].blank? > region = state || country || 'US' > > becomes: > > region = params[:state].nonblank? || params[:country].nonblank? || 'US' > ...
Changing the subject a bit, I've just remembered a feature of Groovy's language that I like and think that Ruby lacks... In Groovy: result = object?.method?.another would mean in Ruby something like: result = object && object.method && object.method.another I wonder if it would be possible to have a similar constructor in Ruby that was more DRY like in Groovy. Groovy's syntax would not be an option to Ruby since Ruby's methods accept method names ending with '?', which is not possible in Groovy. That is a good think but I can't think in an expressive annotation to be added to Ruby... Maybe "object#.method?#.to_s". It definitely has nothing to do with Rails, but maybe there is some way of getting a similar result that is already implemented in ActiveSupport and that I don't know, so I hope you don't mind I ask it here... If you do so, I'm sorry and I promise I won't do it again. Regards, Rodrigo. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
