implement scratch version of each in ruby