Advertisement
saasbook

yield example

Jan 23rd, 2012
5,567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.18 KB | None | 0 0
  1. class RandomSequence
  2.   def initialize(limit,num)
  3.     @limit,@num = limit,num
  4.   end
  5.   def each
  6.     @num.times { yield (rand * @limit).floor }
  7.   end
  8. end
  9.  
  10. n = RandomSequence.new(10,4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement