e$B$-$7$b$H$G$9e(B
String#each_indexe$B!J$He(B
String#each_byteindexe$B!K$H$$$&%a%=%C%I$rDs0F$7$^$9!#e(B
Ruby e$B$G<BAu$9$k$H0J2<$N$h$&$J%a%=%C%I$G$9!#e(B
def each_index
unless block_given? then
Enumerator.new self, :each_index
else
i = 0
while i < length do
yield i
i = i.succ
end
self
end
end
e$BNc$($P0J2<$N$h$&$K;H$$$^$9!#e(B
def tr_succ!
each_index{|i|
self[i] = self[i].succ
}
end
e$BF1$8$3$H$Oe(B each_char.with_index{|c, i| …} e$B$G$G$-$^$9$,!“e(B
e$B!J$I$&$;e(B c
e$B$K%”%/%;%9$9$k$N$G$3$A$i$N$[$&$,M-MQ$+$b$7$l$^$;$s$,!Ke(B
each_index e$B$H=q$$$?$[$&$,!"C1=c$G0U?^$,L@3N$@$H;W$$$^$9!#e(B
e$B@.@%$G$9!#e(B
(2010/05/19 9:02), KISHIMOTO, Makoto wrote:
while i< length do
each_index{|i|
self[i] = self[i].succ
}
end
e$BF1$8$3$H$Oe(B each_char.with_index{|c, i| …} e$B$G$G$-$^$9$,!“e(B
e$B!J$I$&$;e(B c e$B$K%”%/%;%9$9$k$N$G$3$A$i$N$[$&$,M-MQ$+$b$7$l$^$;$s$,!Ke(B
each_index e$B$H=q$$$?$[$&$,!"C1=c$G0U?^$,L@3N$@$H;W$$$^$9!#e(B
e$B$^$:!“HwK:$N$?$a$KDs0F$d%P%0Js9p$J$I!”%H%i%C%-%s%0$NI,MW$,$"$k$b$N$Oe(B
Redmine e$B$Ne(B
e$B%A%1%C%H$H$7$FD:$1$k$H$"$j$,$?$$$G$9!#e(B
e$B<!$KDs0F<+BN$G$9$,!"$3$NDs0F$Oe(B String#each
e$B$r:o=|$7$?M}M3$KH?$7$^$9!#e(B
(String e$B$Ne(B each e$BBP>]$K$Oe(B line/character/codepoint/byte
e$B$,$"$k$?$ae(B)
(e$B$J$*!“e(B1.8 e$B$G$Ne(B each e$BBP>]$Oe(B line e$B$G$”$C$?e(B)
e$B$^$?!"F1$8$3$H$Oe(B str.chars.with_index{|c, i| …}
e$B$G$G$-$+$D$3$A$i$NJ}$,L@2w$G$9$7!"e(B
String#each e$B$r:o=|$7$?$3$H$r9M$($l$P$3$A$i$NJ}$,e(B chars
e$B$HL@<($7$F$$$kJ,$h$$$H;W$$$^$9!#e(B
e$B$b$C$H8@$($P!"$3$N%f!<%9%1!<%9$N>l9ge(B str.gsub(/./m){$&.succ}
e$B$H$7$?J}$,9bB.$J$N$G$Oe(B
e$B$J$$$+$H;W$$$^$9!#e(B
e$B$-$7$b$H$G$9e(B
e$B$^$:!“HwK:$N$?$a$KDs0F$d%P%0Js9p$J$I!”%H%i%C%-%s%0$NI,MW$,$"$k$b$N$Oe(B Redmine e$B$Ne(B
e$B%A%1%C%H$H$7$FD:$1$k$H$"$j$,$?$$$G$9!#e(B
e$B$o$+$j$^$7$?!#$^$:%a!<%k$NH?1~$r8+$F$+$i!"$H$+;W$C$?$N$G$9$,!#e(B
e$B<!$+$ie(BMLe$BO"7H$Ge(Bredminee$B$K$bEPO?$5$l$k$h$&$K$7$^$9!#e(B
e$B<!$KDs0F<+BN$G$9$,!"$3$NDs0F$Oe(B String#each e$B$r:o=|$7$?M}M3$KH?$7$^$9!#e(B
(String e$B$Ne(B each e$BBP>]$K$Oe(B line/character/codepoint/byte e$B$,$"$k$?$ae(B)
(e$B$J$*!“e(B1.8 e$B$G$Ne(B each e$BBP>]$Oe(B line e$B$G$”$C$?e(B)
e$B$=$&$$$&$3$H$K$J$j$^$9$+e(B…e$B!#e(B[], []=
e$B%a%=%C%I$H$N$D$J$,$j$Ge(BArraye$B$HF1$8$K$J$k$+$J$!!“e(B
e$B$H$$$&$N$b$”$C$?$N$G$9$,!JA0$N%a!<%k=q$$$?;~$KK:$l$F$$$?!K!"0l4S@-$Oe(BRubye$B$NL\I8$G$Oe(B
e$B$J$$$s$G$7$?$M!#e(B
e$B@.@%$G$9!#e(B
2010e$BG/e(B5e$B7ne(B19e$BF|e(B11:55 KISHIMOTO, Makoto
[email protected]:
e$B$^$:!“HwK:$N$?$a$KDs0F$d%P%0Js9p$J$I!”%H%i%C%-%s%0$NI,MW$,$“$k$b$N$Oe(B Redmine e$B$Ne(B
e$B%A%1%C%H$H$7$FD:$1$k$H$”$j$,$?$$$G$9!#e(B
e$B$o$+$j$^$7$?!#$^$:%a!<%k$NH?1~$r8+$F$+$i!"$H$+;W$C$?$N$G$9$,!#e(B
e$B<!$+$ie(BMLe$BO"7H$Ge(Bredminee$B$K$bEPO?$5$l$k$h$&$K$7$^$9!#e(B
e$BESCf$G0\F0$9$k$H8e$G5DO@$,DI$$$E$i$/$J$k$N$G$9$h!#e(B
e$B<!$KDs0F<+BN$G$9$,!“$3$NDs0F$Oe(B String#each e$B$r:o=|$7$?M}M3$KH?$7$^$9!#e(B
(String e$B$Ne(B each e$BBP>]$K$Oe(B line/character/codepoint/byte e$B$,$”$k$?$ae(B)
(e$B$J$*!“e(B1.8 e$B$G$Ne(B each e$BBP>]$Oe(B line e$B$G$”$C$?e(B)
e$B$=$&$$$&$3$H$K$J$j$^$9$+e(B…e$B!#e(B[], []= e$B%a%=%C%I$H$N$D$J$,$j$Ge(BArraye$B$HF1$8$K$J$k$+$J$!!“e(B
e$B$H$$$&$N$b$”$C$?$N$G$9$,!JA0$N%a!<%k=q$$$?;~$KK:$l$F$$$?!K!"0l4S@-$Oe(BRubye$B$NL\I8$G$Oe(B
e$B$J$$$s$G$7$?$M!#e(B
e$B0l4S@-$K4X$7$F$O!V:GM%@h$G$O$J$$!W$G$9$M!#e(B
e$B2?$+$rMWK>$9$k:]$N:,5r$N0l$D$K0l4S@-$rF~$l$F$*$/$3$H$OM-8z$G$O$"$j$^$9!#e(B
e$B$G!"0l4S@-$rMW5a$9$k$J$ie(B
- String#each e$B$re(B String#each_char e$B$Ne(B alias e$B$H$7$FI|3he(B
- String e$B$re(B Enumerable e$B$K$7$J$*$9e(B
e$B$"$?$j$rDs0F$9$k$Y$-$8$c$J$$$G$9$+$Me(B