:FOO === "FOO" => true and case/when behavior


#1

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

e$B0J2<$N%9%/%j%W%H$r<B9T$9$k$He(B:


p :FOO === “FOO”

FOO = :FOO

case “FOO”
when FOO
puts 1
else
puts 0
end

case “FOO”
when :FOO
puts 1
else
puts 0
end

e$B0J2<$N$h$&$J7k2L$K$J$j$^$9e(B:


emperor2% ruby-dev -v /tmp/g.rb
ruby 1.9.0 (2008-11-04 revision 20106) [i686-linux]
true
1
0

2e$B$D<ALd$,$"$C$Fe(B,

:FOO === “FOO” ==> true

e$B$K$J$k$N$O;EMM$J$N$+e(B? e$B$H$$$&$3$H$He(B,

e$B>e5-$Ne(B case/when
e$B$N?6$kIq$$$,0[$J$k$N$+$,NI$/M}2r$G$-$J$$$N$G$9$,e(B, e$B$Je(B
e$B$<$G$7$g$&$+e(B?

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#2

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

In message “Re: [ruby-dev:37026] :FOO === “FOO” => true and case/when
behavior”
on Thu, 6 Nov 2008 21:46:18 +0900, removed_email_address@domain.invalid (Keiju
ISHITSUKA) writes:

|2e$B$D<ALd$,$"$C$Fe(B,
|
| :FOO === “FOO” ==> true
|
|e$B$K$J$k$N$O;EMM$J$N$+e(B? e$B$H$$$&$3$H$He(B,

e$B$"!<!"%P%0$G$9!#e(BSymbol#===e$B$O0JA0e(BSymbole$B$He(BStringe$B$N8_49@-$r9b$ae(B
e$B$?;~$NL>;D$G8=:_$OITMW$J$b$N$G$9!#D>$7$^$9!#e(B

|e$B>e5-$Ne(B case/when e$B$N?6$kIq$$$,0[$J$k$N$+$,NI$/M}2r$G$-$J$$$N$G$9$,e(B, e$B$Je(B
|e$B$<$G$7$g$&$+e(B?

e$B$(!<$H!"$*$=$i$/$Oe(Bwhene$B$G;XDj$7$?CM$,%j%F%i%k$G$"$k>l9g!":GE,e(B
e$B2=$,9T$o$l$F!"$=$A$i$O>e5-$N!V%P%0!W$r9MN8$7$F$$$J$$$+$i$G$Oe(B
e$B$J$$$G$7$g$&$+!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

#3

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev :37030 ] the message: "[ruby-dev:37030] Re: :FOO ===
“FOO” => true and case/when behavior ", on Nov/07 06:56(JST) Yukihiro
Matsumoto writes:

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

e$B$"!<!"%P%0$G$9!#e(BSymbol#===e$B$O0JA0e(BSymbole$B$He(BStringe$B$N8_49@-$r9b$ae(B
e$B$?;~$NL>;D$G8=:_$OITMW$J$b$N$G$9!#D>$7$^$9!#e(B

e$BF0:n3NG’$7$^$7$?e(B.

e$B$(!<$H!"$*$=$i$/$Oe(Bwhene$B$G;XDj$7$?CM$,%j%F%i%k$G$"$k>l9g!":GE,e(B
e$B2=$,9T$o$l$F!"$=$A$i$O>e5-$N!V%P%0!W$r9MN8$7$F$$$J$$$+$i$G$Oe(B
e$B$J$$$G$7$g$&$+!#e(B

e$B7k9=HyL/$J:GE,2=$J$s$G$9$Me(B:

case “FOO”
when :FOO
puts 1
else
puts 0
end

BAR = 1

case “FOO”
when BAR
puts :BAR
when :FOO
puts 1
else
puts 0
end

e$B>e$H$7$?$G$Oe(B, when :SYMBOL e$B$N07$$$,0c$C$F$$$k$s$G$9$Me(B.

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#4

e$BKNIt$G$9!#e(B

Yukihiro M. e$B$5$s$O=q$-$^$7$?e(B:

e$B$"!<!"%P%0$G$9!#e(BSymbol#===e$B$O0JA0e(BSymbole$B$He(BStringe$B$N8_49@-$r9b$ae(B
e$B$?;~$NL>;D$G8=:_$OITMW$J$b$N$G$9!#D>$7$^$9!#e(B

e$BITMW$J$b$N$J$N$G$9$+e(B?
e$B$3$N;EMM$K0MB8$7$?%3!<%I$,$"$C$?$N$G$9$,!"$;$a$Fe(B1.9.1e$B$@$1$G$b$b$H$KLa$je(B
e$B$^$;$s$+e(B?

e$B$C$F$+:#99e(B1.9.1e$B$G?6$kIq$$$,JQ$o$k$H$O;W$C$F$J$+$C$?$N$GIT0U$r$D$+$l$?e(B


#5

Yuguie$B$G$9!#e(B

Urabe S. e$B$5$s$O=q$-$^$7$?e(B:

e$BITMW$J$b$N$J$N$G$9$+e(B?
e$B$3$N;EMM$K0MB8$7$?%3!<%I$,$"$C$?$N$G$9$,!"$;$a$Fe(B1.9.1e$B$@$1$G$b$b$H$KLa$je(B
e$B$^$;$s$+e(B?

e$B$C$F$+:#99e(B1.9.1e$B$G?6$kIq$$$,JQ$o$k$H$O;W$C$F$J$+$C$?$N$GIT0U$r$D$+$l$?e(B

e$B$3$l$OL@$i$+$K%P%0$@$7!"0MB8$7$F$k%3!<%I$b$=$&$=$&$J$$$@$m$&$HH=CG$7$F<he(B
e$B$j9~$_$^$7$?!#;29M$^$G$K0MB8%3!<%I$NNc$r$$$?$@$1$^$;$s$+e(B?


#6

Yugui (Yuki S.) e$B$5$s$O=q$-$^$7$?e(B:

e$B$3$l$OL@$i$+$K%P%0$@$7!"0MB8$7$F$k%3!<%I$b$=$&$=$&$J$$$@$m$&$HH=CG$7$F<he(B
e$B$j9~$_$^$7$?!#;29M$^$G$K0MB8%3!<%I$NNc$r$$$?$@$1$^$;$s$+e(B?

e$B$($C$H!"0lIt$N?M$K$O$^$?$+$h$C$F8@$o$l$=$&$J$s$G$9$1$I!"e(BHashe$B$He(BProce$B$H;H$Ce(B
e$B$Fe(BPythone$B$H$+e(BJavaScripte$B$_$?$$$J%*%V%8%’%/%H$r:n$C$F$?$o$1$G$9!#e(B

class Hash
def method_missing mid, *a, &b;
case mid.to_s.chomp(’=’)
when *self.keys then fetch(mid).call(*a, &b)
end
end
end

{ foo: -> { p self},
bar: -> x, y { x.send y } }.foo

e$B$3$&$$$&$N$M!#e(B