First off, puts is not a function. It's sole purpose is to have a side-effect (printing something to the console), whereas functions
cannot have side-effects ... that's the definition of "function",
after all.
Ruby doesn't have functions. It only has methods. Thus, puts is a method.
Is this true ? So basically, 'puts' is just a "thing" to enable printing something to the console ...
"2.3.0"irb(main):002:0> puts.class
NilClassirb(main):003:0>
irb(main):001:0> RUBY_VERSION
"2.3.0"irb(main):002:0> puts.class
NilClassirb(main):003:0>
Looks like `puts' is an instance of NilClass. And therefore an object.
#<Method: Object(Kernel)#puts>irb(main):002:0> _.owner
Kernel
First off, puts is not a function. It's sole purpose is to have a
side-effect (printing something to the console), whereas functions
cannot have side-effects ... that's the definition of "function",
after all.
Ruby doesn't have functions. It only has methods. Thus, puts is a
method.
Is this true ?
So basically, 'puts' is just a "thing" to enable
printing something to the console ...
First off, puts is not a function. It's sole purpose is to have a
side-effect (printing something to the console), whereas functions
cannot have side-effects ... that's the definition of "function",
after all.
This is ridiculous - or an attempt at humor. [Snip..]
On 2016-04-16 1:45, Robert Klemme <shortcutter@googlemail.com> wrote:
> This is ridiculous - or an attempt at humor. [Snip..]
Perhaps a combination of both ;-)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 286 |
Nodes: | 16 (2 / 14) |
Uptime: | 90:50:45 |
Calls: | 6,496 |
Calls today: | 7 |
Files: | 12,100 |
Messages: | 5,277,686 |