# Case/when splat

e\$B!!\$5\$5\$@\$G\$9!#e(B

e\$B!!<!\$N%W%m%0%i%`\$Oe(B :ok e\$B\$H=PNO\$9\$k\$Y\$-\$@\$H;W\$&\$N\$G\$9\$,!"e(Bruby
1.9.0
(2006-11-03) [x86_64-linux] e\$B\$G\$Oe(B :ng2 e\$B\$H=PNO\$5\$l\$^\$9!#e(B

``````  ary = [1, 2]
p case 1
when :x, *ary
:ok
when :z
:ng1
else
:ng2
end
``````

e\$B!!<!\$N%W%m%0%i%`\$Oe(B :ok
e\$B\$HI=<(\$5\$l\$k\$N\$+\$J!<\$H;W\$C\$F\$\$\$?\$s\$G\$9\$,!"e(B:ng e\$B\$He(B
e\$BI=<(\$5\$l\$^\$9!#\$=\$s\$J\$b\$s\$G\$7\$g\$&\$+!#e(B

``````  ary = []
p case
when false, *ary
:ng
else
:ok
end``````

e\$B\$^\$D\$b\$He(B e\$B\$f\$-\$R\$m\$G\$9e(B

In message “Re: [ruby-dev:29882] Re: case/when splat”
on Tue, 7 Nov 2006 00:12:33 +0900, Nobuyoshi N.
[email protected] writes:

|> e\$B!!<!\$N%W%m%0%i%`\$Oe(B :ok e\$B\$HI=<(\$5\$l\$k\$N\$+\$J!<\$H;W\$C\$F\$\$\$?\$s\$G\$9\$,!"e(B:ng e\$B\$He(B
|> e\$BI=<(\$5\$l\$^\$9!#\$=\$s\$J\$b\$s\$G\$7\$g\$&\$+!#e(B
|
|e\$B\$=\$s\$J\$b\$s\$G\$b\$J\$\$\$G\$7\$g\$&!#e(B

e\$B%P%0\$G\$7\$g\$&\$M!#e(B

|when_check()e\$B\$N9=B\$\$,>/!9\$\$\$^\$\$\$A\$C\$]\$\$\$G\$9\$,!#e(B

e\$B\$3\$l\$GD>\$j\$^\$9\$M!#<h\$j9~\$_\$^\$9!#e(B1.9CVSe\$B%U%j!<%:\$,6a\$\$\$N\$G!";de(B
e\$B\$NJ}\$G:n6H\$7\$^\$9!#e(B

e\$B\$J\$+\$@\$G\$9!#e(B

At Mon, 6 Nov 2006 14:35:02 +0900,

e\$B!!<!\$N%W%m%0%i%`\$Oe(B :ok e\$B\$H=PNO\$9\$k\$Y\$-\$@\$H;W\$&\$N\$G\$9\$,!"e(Bruby 1.9.0
(2006-11-03) [x86_64-linux] e\$B\$G\$Oe(B :ng2 e\$B\$H=PNO\$5\$l\$^\$9!#e(B

e\$B\$Y\$-\$@\$H;W\$\$\$^\$9!#e(B

e\$B!!<!\$N%W%m%0%i%`\$Oe(B :ok e\$B\$HI=<(\$5\$l\$k\$N\$+\$J!<\$H;W\$C\$F\$\$\$?\$s\$G\$9\$,!"e(B:ng e\$B\$He(B
e\$BI=<(\$5\$l\$^\$9!#\$=\$s\$J\$b\$s\$G\$7\$g\$&\$+!#e(B

e\$B\$=\$s\$J\$b\$s\$G\$b\$J\$\$\$G\$7\$g\$&!#e(B

when_check()e\$B\$N9=B\$\$,>/!9\$\$\$^\$\$\$A\$C\$]\$\$\$G\$9\$,!#e(B

# Index: eval.c

RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.955
diff -p -U 2 -r1.955 eval.c
— eval.c 6 Nov 2006 10:27:58 -0000 1.955
+++ eval.c 6 Nov 2006 14:34:38 -0000
@@ -2701,8 +2701,8 @@ unknown_node(NODE *volatile node)
when_cond(VALUE v1, VALUE v2)
{

• if (v1 == Qundef) {
• return RTEST(v2);
• if (v1 != Qundef) {
• v2 = rb_funcall2(v2, eqq, 1, &v1);
}
• return RTEST(rb_funcall2(v2, eqq, 1, &v1));
• return RTEST(v2);
}

@@ -2724,5 +2724,7 @@ when_check(NODE *tag, VALUE val, VALUE s
break;
case NODE_SPLAT:

• `````` splat: