Comment on Ruby 2.1: Profiling RubyparentComments−Mithaldu12yI don't write Ruby, but it's close enough to Perl that i can tell you. Precedence is the reason.The first line with more explicit precedence is this: if( params[:user_id].present?) { @owner ||= User.find_by_login(params[:user_id]) } The second line is this: @owner ||= ( User.find_by_login(params[:user_id]) if params[:user_id].present? ) In other words, the first version always ran the present? method, while the second version only did so if @owner was false.
Comments
I don't write Ruby, but it's close enough to Perl that i can tell you. Precedence is the reason.
The first line with more explicit precedence is this:
The second line is this: In other words, the first version always ran the present? method, while the second version only did so if @owner was false.