You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to have exercise solutions. In my case I wanted to verify if my solution to the exercise on page 189 (chapter 6) is correct.
Here is my attempt...
class Array
def my_each
c = 0
until c == size
yield self[c]
c += 1
end
self
end
end
class Integer
def my_times
c = 0
acc = []
until c == self
acc << c
c += 1
end
acc.my_each { |e| yield e }
self
end
end
5.my_times { |i| puts "I'm on iteration #{i}!" }
The text was updated successfully, but these errors were encountered:
It would be great to have exercise solutions. In my case I wanted to verify if my solution to the exercise on page 189 (chapter 6) is correct.
Here is my attempt...
The text was updated successfully, but these errors were encountered: