multiple_distinct_objects.sf 235 B

12345678910111213
  1. #!/usr/bin/ruby
  2. #
  3. ## https://rosettacode.org/wiki/Multiple_distinct_objects
  4. #
  5. class Foo { };
  6. [Foo.new] * 5; # incorrect (only one distinct object is created)
  7. 5.of {Foo.new}; # correct
  8. 1..5 -> map {Foo.new}; # also correct