DEV Community

pooyaalamdari
pooyaalamdari

Posted on

iterator

5.times {|i| puts "I can handle this piece a sheet #{i}"}
Enter fullscreen mode Exit fullscreen mode
array = [1,2,3,4,5]

array.each { |e| puts "say hello #{e}" }
Enter fullscreen mode Exit fullscreen mode
a = [:foo, 'bar', 2]

a.each { |element| puts "#{element.class} #{element}" }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)