Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Really odd method in application

Tags:

ruby

I just came across an odd method in some Ruby code, and I'm wondering if I'm missing something fundamental. It looks like this:

def funny
  !funny
end

What would this possibly return?

like image 429
Matt Grande Avatar asked Dec 23 '22 11:12

Matt Grande


2 Answers

That would run recursively until you get a stack overflow.

like image 182
alexn Avatar answered Jan 02 '23 03:01

alexn


It would recurse until you got a stack overflow.

like image 21
Brian Avatar answered Jan 02 '23 03:01

Brian