I was sharing with some friends how to use if and unless. I wrote this
statement: *puts nil if nil*
and I got =>nil. (Which implies nothing was printed.)
When I wrote: *puts nil unless nil*
I got:
nil
=> nil
Which implies that puts output nil.
My question is what is in *"nil"* that makes "*puts*" print "*nil"*? Or is
there any explanation to back this behaviour?
if (NIL_P(argv[i])) {
line = rb_str_new2("nil");
}
It specifically checks for nil arguments and prints "nil" in that case.
Jesus.
···
On Wed, Nov 10, 2010 at 2:26 PM, Edmond Kachale <edmond.kachale@baobabhealth.org> wrote:
Rubysters,
I was sharing with some friends how to use if and unless. I wrote this
statement: *puts nil if nil*
and I got =>nil. (Which implies nothing was printed.)
When I wrote: *puts nil unless nil*
I got:
nil
=> nil
Which implies that puts output nil.
My question is what is in *"nil"* that makes "*puts*" print "*nil"*? Or is
there any explanation to back this behaviour?
2010/11/10 Jesús Gabriel y Galán <jgabrielygalan@gmail.com>:
On Wed, Nov 10, 2010 at 2:26 PM, Edmond Kachale > <edmond.kachale@baobabhealth.org> wrote:
Rubysters,
I was sharing with some friends how to use if and unless. I wrote this
statement: *puts nil if nil*
and I got =>nil. (Which implies nothing was printed.)
When I wrote: *puts nil unless nil*
I got:
nil
=> nil
Which implies that puts output nil.
My question is what is in *"nil"* that makes "*puts*" print "*nil"*? Or is
there any explanation to back this behaviour?
Ooops, forgot to mention I was answering for MRI 1.8.7, thanks.
Jesus.
···
On Wed, Nov 10, 2010 at 2:40 PM, Robert Klemme <shortcutter@googlemail.com> wrote:
2010/11/10 Jesús Gabriel y Galán <jgabrielygalan@gmail.com>:
On Wed, Nov 10, 2010 at 2:26 PM, Edmond Kachale >> <edmond.kachale@baobabhealth.org> wrote:
Rubysters,
I was sharing with some friends how to use if and unless. I wrote this
statement: *puts nil if nil*
and I got =>nil. (Which implies nothing was printed.)
When I wrote: *puts nil unless nil*
I got:
nil
=> nil
Which implies that puts output nil.
My question is what is in *"nil"* that makes "*puts*" print "*nil"*? Or is
there any explanation to back this behaviour?