define_method :hash_count do
hash = ''
hash << 'X' while hash.length < 25
hash # returns the hash from the method
end
puts hash
私は期待していました
XXXXXXXXXXXXXXXXXXXXXXXX
画面に出力します。代わりに、次のような奇妙な乱数を取得します
3280471151433993928
と
-1945829393073068570
誰か説明してくれませんか?Ruby でのスコーピングは、PHP/Javascript よりも奇妙に思えます!