e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B
In message “Re: [ruby-dev:38500] Re: [Feature:trunk] enhancement of
Array#drop”
on Wed, 20 May 2009 00:06:19 +0900, “U.Nakamura”
[email protected] writes:
|| drop_whilee$B$H$O0c$&$N$G$9$M!#e(B
|
|e$B;d$,40c$$$7$F$J$1$l$P!“e(Bdrop_whilee$B$O!V$”$k>r7o$K9gCW$9$kMWAGe(B
|e$B$h$jA0$NMWAG$rA4$F:o=|$9$k!W$G$9$+$i!";d$,M_$7$$J$H$O0c$&$he(B
|e$B$&$G$9!#e(B
e$B0c$$$^$9!#e(Bdrop_whilee$B$O!V$"$k>r7o$K9gCW$9$k4V!"MWAG$r@hF,$+$ie(B
e$B:o=|$9$k!W$G$9!#e(BRDoce$B$+$iNcBj$r0zMQ$9$k$He(B
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
e$B$G$9!#$3$l$O!"$&$5$5$s$,:G=i$K=q$$$?e(B
Rubye$B$G%9%/%j%W%H$r=q$$$F$$$F!“G[Ns$+$i!”$“$k>r7o$K9gCW$9$k@he(B
e$BF,$NMWAG$N$_$r:o=|$9$k!”$H$$$&=hM}$r=q$-$?$$>lLL$K=P2q$C$?$3e(B
e$B$H$,2?EY$+$"$j$^$9!#e(B
e$B$H$$$&I=8=$K$O9gCW$9$k$H;W$$$^$7$?!#$@$+$i$3$=!"$o$6$o$6e(B
e$B!Ve(Bdrop_while e$B$H$O0c$&$N$G$9$M!W$HJ9$$$?$o$1$G!#e(B
e$B$?$@!"$J$+$@$5$s$,:n$C$?%Q%C%A$N5sF0$,e(B
[:a, :b, :a, :b].drop(1){|e| e == :b} #=> [:a, :a, :b]
[:a, :b, :a, :b].drop(2){|e| e == :b} #=> [:a, :a]
e$B$@$=$&$G$9$+$i!"$3$l$O!V0z?t$G;XDj$7$?HO0OFb$G>r7o$rK~$?$9MWe(B
e$BAG$r:o=|$9$k!W%a%=%C%I$K$J$C$F$$$^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