Why does Ruby expression with double ampersand using a return statement cause a syntax error

Viewed 605
def foo
  true && return false
end

def bar
  true and return false
end

foo method causes a syntax error. bar doesn't. Why?

Assuming I want to evaluate one-liners with a return statement (similar to a certain commonly used shell/bash expression), would this be a recommended way to do it, or is there a more recommended approach?

4 Answers
Related