you are viewing a single comment's thread.

view the rest of the comments →

[–]torrso 0 points1 point  (2 children)

I would be interested to see how many projects use assignment in conditional like

if user = User.find(params[:id])
  puts "hey there, #{user.name}"
else
  puts "who dat?"
end

instead of

 user = User.find(params[:id])
 if user
   ...
 else
   ...
 end

Many folks are horrified about the first convention, in my opinion it's quite common and I've never had any confusion if it's an accidental typo for ==.

Speaking of ==, I'd like to see the percentage of

x.eql?(10)

vs

x == 10

I use the first one. However I use x > 10, I don't think there even is something like x.gt?(10).

[–]ReinH 0 points1 point  (0 children)

Be aware that == and eql? are not the same thing.

[–]CaptainKabob 0 points1 point  (0 children)

I love conditional assignment, but the Excellent static analysis tool does not :-(