If you have either ruby 1.9 or activesupport, you can do simply
@title = tokens[Title].try :tap, &:strip!
This is really cool, as it leverages the :try
and the :tap
method, which are the most powerful functional constructs in ruby, in my opinion.
An even cuter form, passing functions as symbols altogether:
@title = tokens[Title].send :try, :tap, &:strip!