def zundoko z, d = zd = ['ズン', 'ドコ'] w1, w2, w3, w4, w5 = 5.times.map { nil } until [w1, w2, w3, w4, w5] == [z, z, z, z, d] w1, w2, w3, w4, w5 = w2, w3, w4, w5, zd.sample.tap(&method(:print)) end print 'キ・ヨ・シ!' end zundoko Enumerator @yancya 無限に「ズン」「ドコ」のどちらかを出し続けるEnumeratorを作って、each_consがスマートだと思う。 — joker1007に宜しく (@joker1007) 2016年3月11日 なるほど def zundoko z, d = zd = ['ズン', 'ドコ'] loop.lazy.map { zd.