Shuaib Zahda wrote:
> Hi all
> 
> in my program I am using a lot of true false conditions. So, I want to
> shorten my code by using the conditional operator ? : but when I use the
> word return it gives an error which i do not really know why?
> 
> e.g. x == 5 ? return true : return false
> SyntaxError: compile error
> (irb):19: syntax error, unexpected kTRUE
> 
> but if i do not use return it works
> 
> x == 5 ? true : false
> 
> any idea


def f
  x = 4
  x==5 ? (return true) : (return false)
end

puts f
-->false
-- 
Posted via http://www.ruby-forum.com/.