Ruby: "&& return" vs "and return"
Ao ler o guia Rails emhttp://guides.rubyonrails.org/layouts_and_rendering.html#avoiding-double-render-errors , Escrevi um programa de teste para testar o Ruby&& return
, e eu tenho esse comportamento estranho:
def test1
puts 'hello' && return
puts 'world'
end
def test2
puts 'hello' and return
puts 'world'
end
Esta é a saída do resultado:
irb(main):028:0> test1
=> nil
irb(main):029:0> test2
hello
world
=> nil
O que explica a diferença?