0


if a==0 then return b else return c end

return a==0 and b or c

other than the latter being shorter, are there any significant differences between the two? by differences i mean things such as performance, outputs, etc...

flag offensive
asked 2010-10-14 01:51:49.599297
1
add comment
1 Answers:
0


There's only a small catch:

b cannot evaluate to a false value (false and nil), in all other cases, the two are nearly equivalent (The second one accumulates a little bit more overhead as it must evaluate the or clause, but the order of magnitude of the execution time are equivalent).

permanent link | flag offensive
answered 2010-10-14 13:54:24.441001
41
add comment
Your answer:
You are now not logged in but you can answer first and then login
toggle preview



Tags:

× 1

Asked: 1 year, 4 months ago

Seen: 783 times

Last updated: 1 year, 4 months ago

Related questions


Made with Django.