Let's start off with a fairly easy one.
code: |
irb(main):001:0> true | puts("or")
or
=> true |
Explain why "or" is output, despite the fact that the '|' operator should know the whole expression is true after seeing the initial 'true', since true or something is true.
This next TYS is tough, I think, but it's worth it. It's quite fun.
In
one line of code, write a program that computes the factorial of a given number. I say it in this manner because I'm not asking you to write a function. Indeed, there is to be no use of "def" or "while" or "loop" any other looping structure.
I'm being kind of vague about this because otherwise I'll give too much away. Feel free to post answers; if it's not what I'm looking for, I'll let you know.
Addendum: I want a recursive solution. But keep in mind, you can't define any methods!