J
John Joyce
I've seen this in Rails, but it is just ERb, so it is Ruby...
<%= link_to 'Previous page', {
age =>
@product_pages.current.previous } if @product_pages.current.previous %>
I'm curious how it is different from this...
<%= if @product_pages.current.previous link_to ('Previous page',
{
age => @product_pages.current.previous })
end
%>
I've seen this kind of if statement reversal a few times now in Ruby
code. I call it do-if because it looks similar to do-while, but I am
curious if reversing the condition affects the interpreter's speed at
all. If they are the same, then isn't the standard if conditional
better for human legibility and understanding?
<%= link_to 'Previous page', {
@product_pages.current.previous } if @product_pages.current.previous %>
I'm curious how it is different from this...
<%= if @product_pages.current.previous link_to ('Previous page',
{
end
%>
I've seen this kind of if statement reversal a few times now in Ruby
code. I call it do-if because it looks similar to do-while, but I am
curious if reversing the condition affects the interpreter's speed at
all. If they are the same, then isn't the standard if conditional
better for human legibility and understanding?