M
Marcin Górski
Hi,
I would like to know if there is possibility to add values like but have
a few elemens with the same value:
irb(main):002:0> require 'set'
=> true
irb(main):003:0> a = Set.new
=> #<Set: {}>
irb(main):004:0> a.add(1)
=> #<Set: {1}>
irb(main):005:0> a.add(1)
=> #<Set: {1}>
irb(main):006:0> a.add(1)
=> #<Set: {1}>
irb(main):007:0> a.add(2)
=> #<Set: {1, 2}>
irb(main):008:0> a.add(3)
=> #<Set: {1, 2, 3}>
irb(main):009:0> a.add(4)
=> #<Set: {1, 2, 3, 4}>
irb(main):010:0> a.add(5)
=> #<Set: {5, 1, 2, 3, 4}>
irb(main):011:0> a.add(6)
=> #<Set: {5, 6, 1, 2, 3, 4}>
irb(main):012:0> a.add(1)
=> #<Set: {5, 6, 1, 2, 3, 4}>
It would be nice to have for example {5, 1, 1, 1} in Set class object.
Is it possible? Which method should I use to add element in that way?
I would like to know if there is possibility to add values like but have
a few elemens with the same value:
irb(main):002:0> require 'set'
=> true
irb(main):003:0> a = Set.new
=> #<Set: {}>
irb(main):004:0> a.add(1)
=> #<Set: {1}>
irb(main):005:0> a.add(1)
=> #<Set: {1}>
irb(main):006:0> a.add(1)
=> #<Set: {1}>
irb(main):007:0> a.add(2)
=> #<Set: {1, 2}>
irb(main):008:0> a.add(3)
=> #<Set: {1, 2, 3}>
irb(main):009:0> a.add(4)
=> #<Set: {1, 2, 3, 4}>
irb(main):010:0> a.add(5)
=> #<Set: {5, 1, 2, 3, 4}>
irb(main):011:0> a.add(6)
=> #<Set: {5, 6, 1, 2, 3, 4}>
irb(main):012:0> a.add(1)
=> #<Set: {5, 6, 1, 2, 3, 4}>
It would be nice to have for example {5, 1, 1, 1} in Set class object.
Is it possible? Which method should I use to add element in that way?