4 ms·
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: if(
by Mithaldu 13y ago
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:
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.