When *a

[email protected]$G$9!#e(B

e$B<!$N$h$&$K!"e(Bwhen *a e$B$,F0:n$7$J$/$J$C$F$$$^$9!#e(B

~/c/refe % cat t
case “string”
when *[/s/]
puts “OK”
else
puts “NG”
end

~/c/refe % ruby-1.8.4 -v t
ruby 1.8.4 (2005-12-24) [x86_64-linux]
OK
~/c/refe % ruby -v t
ruby 1.9.0 (2006-06-23) [x86_64-linux]
NG

[email protected]$G$9!#e(B

At Sat, 24 Jun 2006 14:14:15 +0900,
Minero A. wrote in [ruby-dev:28822]:

e$B<!$N$h$&$K!"e(Bwhen *a e$B$,F0:n$7$J$/$J$C$F$$$^$9!#e(B

e$B$3$s$J$H$3$G$7$g$&$+!#e(B

Index: eval.c

RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.903
diff -p -U2 -r1.903 eval.c
— eval.c 23 Jun 2006 08:28:04 -0000 1.903
+++ eval.c 24 Jun 2006 13:32:04 -0000
@@ -2855,6 +2855,6 @@ rb_eval(VALUE self, NODE *n)
ruby_frame->this_func,
ruby_frame->this_class);

  •       if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
    
  •   	VALUE v = rb_eval(self, tag->nd_head->nd_head);
    
  •       if (nd_type(tag) == NODE_SPLAT) {
    
  •   	VALUE v = rb_eval(self, tag->nd_head);
      	long i;

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

In message “Re: [ruby-dev:28827] Re: when *a”
on Sat, 24 Jun 2006 22:33:25 +0900, [email protected] writes:

|At Sat, 24 Jun 2006 14:14:15 +0900,
|Minero A. wrote in [ruby-dev:28822]:
|> e$B<!$N$h$&$K!"e(Bwhen *a e$B$,F0:n$7$J$/$J$C$F$$$^$9!#e(B
|
|e$B$3$s$J$H$3$G$7$g$&$+!#e(B

e$B%3%_%C%H$7$F$/[email protected]$5$$!#e(B

[email protected]$G$9!#e(B

At Sat, 24 Jun 2006 23:53:27 +0900,
Yukihiro M. wrote in [ruby-dev:28829]:

|At Sat, 24 Jun 2006 14:14:15 +0900,
|Minero A. wrote in [ruby-dev:28822]:
|> e$B<!$N$h$&$K!"e(Bwhen *a e$B$,F0:n$7$J$/$J$C$F$$$^$9!#e(B
|
|e$B$3$s$J$H$3$G$7$g$&$+!#e(B

e$B%3%_%C%H$7$F$/[email protected]$5$$!#e(B

[email protected]$He(B when /b/, *[/a/]
e$B$N$h$&$J>l9g$KF0:n$7$F$^$;$s$G$7$?!#e(B
e$B8=>u$G$Oe(Bargse$B$r$=$N$^$^;H$&$h$&$K$J$C$F$$$^$9$,!"!V$R$H$D$R$H$De(B
e$BI>2A$7$F$O%^%C%A$5$;$k!W$H$$$&F0:n$K$OIT8~$-$G$9!#e(Bwhen_argse$B$rI|e(B
e$B3h$5$;$?$[$&$,$$$$$h$&$J5$$,$7$^$9!#e(B

Index: eval.c

RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.903
diff -p -U2 -r1.903 eval.c
— eval.c 23 Jun 2006 08:28:04 -0000 1.903
+++ eval.c 25 Jun 2006 08:01:46 -0000
@@ -2855,5 +2868,5 @@ rb_eval(VALUE self, NODE *n)
ruby_frame->this_func,
ruby_frame->this_class);

  •       if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
    
  •       if (tag->nd_head && nd_type(tag->nd_head) == NODE_SPLAT) {
      	VALUE v = rb_eval(self, tag->nd_head->nd_head);
      	long i;
    

Index: parse.y

RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.443
diff -p -U2 -r1.443 parse.y
— parse.y 21 Jun 2006 08:08:34 -0000 1.443
+++ parse.y 25 Jun 2006 07:56:00 -0000
@@ -533,5 +536,5 @@ static void ripper_compile_error(struct
%type expr_value arg_value primary_value
%type if_tail opt_else case_body cases opt_rescue exc_list
exc_var opt_ensure
-%type args call_args call_args2 opt_call_args
+%type args when_args call_args call_args2 opt_call_args
%type open_args paren_args opt_paren_args
%type command_args aref_args opt_block_arg block_arg var_ref
var_lhs
@@ -3377,5 +3385,5 @@ brace_block : ‘{’
;

-case_body : kWHEN args then
+case_body : kWHEN when_args then
compstmt
cases
@@ -3389,4 +3397,38 @@ case_body : kWHEN args then
;

+when_args : arg_value

  •       {
    
  •       /*%%%*/
    
  •   	$$ = NEW_LIST($1);
    
  •       /*%
    
  •   	$$ = arg_add(arg_new(), $1);
    
  •       %*/
    
  •       }
    
  •   | tSTAR arg_value
    
  •       {
    
  •       /*%%%*/
    
  •   	$$ = NEW_LIST(NEW_SPLAT($2));
    
  •       /*%
    
  •   	$$ = arg_add_star(arg_new(), $2);
    
  •       %*/
    
  •       }
    
  •   | when_args ',' arg_value
    
  •       {
    
  •       /*%%%*/
    
  •   	$$ = list_append($1, $3);
    
  •       /*%
    
  •   	$$ = arg_add($1, $3);
    
  •       %*/
    
  •       }
    
  •   | when_args ',' tSTAR arg_value
    
  •       {
    
  •       /*%%%*/
    
  •   	$$ = list_append($1, NEW_SPLAT($4));
    
  •       /*%
    
  •   	$$ = arg_add_star($1, $4);
    
  •       %*/
    
  •       }
    
  •   ;
    

cases : opt_else
| case_body

[email protected]$G$9!#e(B

At Wed, 28 Jun 2006 00:52:05 +0900,
Yukihiro M. wrote in [ruby-dev:28871]:

|[email protected]$He(B when /b/, *[/a/] e$B$N$h$&$J>l9g$KF0:n$7$F$^$;$s$G$7$?!#e(B
|e$B8=>u$G$Oe(Bargse$B$r$=$N$^$^;H$&$h$&$K$J$C$F$$$^$9$,!"!V$R$H$D$R$H$De(B
|e$BI>2A$7$F$O%^%C%A$5$;$k!W$H$$$&F0:n$K$OIT8~$-$G$9!#e(Bwhen_argse$B$rI|e(B
|e$B3h$5$;$?$[$&$,$$$$$h$&$J5$$,$7$^$9!#e(B

when_argse$B$rI|3h$5$;$F$b$$$$$G$9$1$I!"$=$N>l9g$K$Oe(Bmulti splat
e$B$KBP1~$5$;$kI,MW$,$"$k$H;W$$$^$9!#$=$l$,LLE]$Ge(Bargse$B$r$=$N$^$^e(B
e$B;H$C$F$k$o$1$G$9$,!#e(B

[ruby-dev:28844]e$B$OBP1~$7$F$k$O$:$G$9$,!#$H$$$&$N$O$H$b$+$/!"e(B

case “b” when *[/a/], /b/; end

e$B$,e(Bunknown node typee$B$K$J$j$^$9!#e(B

Index: eval.c

RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.909
diff -p -U2 -r1.909 eval.c
— eval.c 27 Jun 2006 23:13:19 -0000 1.909
+++ eval.c 28 Jun 2006 03:55:00 -0000
@@ -2712,5 +2712,6 @@ when_check(NODE *tag, VALUE val, VALUE s
return when_check(tag->nd_body, val, self);
default:

  • unknown_node(tag);
  • if (when_cond(val, rb_eval(self, tag))) return Qtrue;
  • break;
    }
    return Qfalse;

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

In message “Re: [ruby-dev:28879] Re: when *a”
on Wed, 28 Jun 2006 12:57:07 +0900, [email protected] writes:

|[ruby-dev:28844]e$B$OBP1~$7$F$k$O$:$G$9$,!#e(B

e$B$"$l!)e(B

|e$B$H$$$&$N$O$H$b$+$/!"e(B
|
| case “b” when *[/a/], /b/; end
|
|e$B$,e(Bunknown node typee$B$K$J$j$^$9!#e(B

e$B$7$^$C$?!#%3%_%C%H$7$F$/[email protected]$5$$!#e(B

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

In message “Re: [ruby-dev:28844] Re: when *a”
on Sun, 25 Jun 2006 18:42:58 +0900, [email protected] writes:

|[email protected]$He(B when /b/, *[/a/] e$B$N$h$&$J>l9g$KF0:n$7$F$^$;$s$G$7$?!#e(B
|e$B8=>u$G$Oe(Bargse$B$r$=$N$^$^;H$&$h$&$K$J$C$F$$$^$9$,!"!V$R$H$D$R$H$De(B
|e$BI>2A$7$F$O%^%C%A$5$;$k!W$H$$$&F0:n$K$OIT8~$-$G$9!#e(Bwhen_argse$B$rI|e(B
|e$B3h$5$;$?$[$&$,$$$$$h$&$J5$$,$7$^$9!#e(B

when_argse$B$rI|3h$5$;$F$b$$$$$G$9$1$I!"$=$N>l9g$K$Oe(Bmulti splat
e$B$KBP1~$5$;$kI,MW$,$"$k$H;W$$$^$9!#$=$l$,LLE]$Ge(Bargse$B$r$=$N$^$^e(B
e$B;H$C$F$k$o$1$G$9$,!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs