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%/%;%9

$B%"%/%;%9%f!<%F%#%j%F%#7?(B

$BE57?E*$JNc$O(B Array#each_index$B!"(BString#each$B!"(BInteger#upto $B$J$I!#(B

$B%*%V%8%'%/%H$rArray#each_index $B$O%V%m%C%/$N0z?t$O(B Array $B$K(B$B4X78$7$F$O$$$k(B$B$1(B $B$l$I$b!"(B$B;}$C$F$$$k(B$B$o$1$G$O$J$$!#$=$l$f$(!"MWAG%"%/%;%97?$H$O(B $B0c$C$F!"0z?t$N%*%V%8%'%/%H$rGK2uE*$KJQ99$7$F$bI{:nMQ$,$*$-$J$$$3$H$,B?(B $B$$!#$3$N%?%$%W$N%a%=%C%I$O$?$$$F$$%f!<%6%l%Y%k$G$bDj5A$G$-$k$N$@$,!"%f!<(B $B%6$N4JJX$N$?$a$KDs6!$5$l$F$$$k!"$9$J$o$A%f!<%F%#%j%F%#$G$"$k!#(B

$BHO0O7?(B

$BE57?E*$JNc$O(B IO#open$B!"(Btimeout $B$J$I!#(B

$B%$%F%l!<%?%V%m%C%/$Nensure $B$H$/$_$"$o$;$F3N

$B$A$J$_$K(B C $B$N(B malloc $B$J$s$+$OHO0O7?%$%F%l!<%?$K$G$-$F$b$h$5$=$&$G$"$k!#(B $B9M$($k$@$1L5BL$+!#(B

$BEPO?7?(B

$BE57?E*$JNc$O(B signal$B!"(BGtk::Widget#signal_connect $B$J$I!#(B

$B$$$o$f$k%3!<%k%P%C%/%k!<%A%s$NEPO?$G$"$k!#$3$N%?%$%W$K4X$7$F$O!"H$5$l$?$7!#(B

$B%Q%i%a!<%?7?(B

$BE57?E*$JNc$O(B Enumerable#collect$B!"(BArray#delete_if $B$J$I!#(B

$B%*%V%8%'%/%H$r%Q%i%a!<%?2=$7$?$$;~$O0z?t$rEO$9!#0lJ}!"%3!<%I$r%Q%i%a!<(B $B%?2=$7$?$$;~$O%$%F%l!<%?$r;H$C$F%V%m%C%/$rEO$9!#%F%s%W%l!<%H%a%=%C%I$H(B $B$+%9%H%i%F%8!<$H8F$P$l$k$b$N$,$3$NHOaF$G$"$k!#$3$N%?%$%W$O%V%m%C%/$NJV(B $B$jCM$K0UL#$,$"$k$3$H$,B?$$!#(B

$B;E;vJ,3d7?(B

$BIO#each$B!"(BSMTP#sendmail $B$J$I!#(B

$B7k2LA4It$r0l5$$KJV$9$H$G$+$9$.$F4m81$J;~$K!"J8;zNs(B($B$H$+(B)$B$r>/$7$E$DEO$9(B $B%?%$%W!#(BIO#each $B$O$I$C$A$+$H$$$&$H9T$KJ,3d$9$k$[$&$,L\E*$@$H;W$&$,!"$=(B $B$&$$$&L\E*$K$b(B($B3N

$B%3%s%F%-%9%H7?(B

$BE57?E*$JNc$O(B module_eval $B$H(B instance_eval.

$B$3$N%?%$%W$O%V%m%C%/$r(B eval $B$9$k$3$H$,L\E*$H$$$C$F$$$$!#B>$NNc$O$"$^$j(B $B8+$i$l$J$$$N$@$,!"$*$l$O7k9=;H$C$F$k!#;H$$$?$/$J$k$N$O!"Nc$($P!V$A$g$C(B $B$H$7$?4D6-$,M_$7$$!W!V$3$3$@$1$GDLMQ$9$k%a%=%C%I$rDj5A$7$?$$!W!V;H$$

def mkenv( &block )
  Object.new.instance_eval(&block)
end

mkenv {
  def put( msg )
    $stderr.puts msg
  end
  put 'test, test...'
  put 'tadaima maikuno tesuto tyuu.'
}

$B%V%m%C%/$,=*$o$C$F$7$^$($P(B put $B$O$I$3$K$b;D$i$J$$!#$^$@(B GC $B$5$l$F$J$1(B $B$l$P(B ObjectSpace $B$r6n;H$7$F$J$s$H$+$J$k$,$=$s$J$3$H$^$G;XE&$9$k$d$D$O(B $B$a$C$?$K$$$J$$$@$m$&!#$A$J$_$K$=$l$9$i$bDLMQ$7$J$$$h$&$K$9$k$J$i(B mkenv $B$N:G8e$G(B GC.start $B$9$l$P$$$$$3$H$@!#!DK\Ev$K$d$k$J$h!#(B

$B%a%=%C%I%3!<%k$H$NHf3S(B

$B$[$H$s$I$N%$%F%l!<%?$O!"%a%=%C%I(B ID $B$H%l%7!<%P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