B
Brian Schröder
Hello Group,
I just noticed the following behaviour:
$ irb --prompt-mode xmp
*[:x]
SyntaxError: compile error
(irb):1: syntax error
from (irb):1
a=*[:x]
==>:x
and wondered why it is the case. I always understood the * operator as pack/unpack array operator. So I would have expected the following behaviour.
*[:x] => :x
What is the reason for * being implemented as it is?
After reading this again I see, that it may be the problem with
*[:x, :y] => ???
So in fact maybe I should not wonder. So let me rephrase it into "what exactly does the * return", because I thought "every ruby expressions retruns something" and a = *[:x] are two expressions.
And is the * a private kernel method or where is it defined?
Regards,
Brian
PS: Sorry if this is a dumb question.
I just noticed the following behaviour:
$ irb --prompt-mode xmp
*[:x]
SyntaxError: compile error
(irb):1: syntax error
from (irb):1
a=*[:x]
==>:x
and wondered why it is the case. I always understood the * operator as pack/unpack array operator. So I would have expected the following behaviour.
*[:x] => :x
What is the reason for * being implemented as it is?
After reading this again I see, that it may be the problem with
*[:x, :y] => ???
So in fact maybe I should not wonder. So let me rephrase it into "what exactly does the * return", because I thought "every ruby expressions retruns something" and a = *[:x] are two expressions.
And is the * a private kernel method or where is it defined?
Regards,
Brian
PS: Sorry if this is a dumb question.