Sunday, April 17, 2011

Ruby Programming Language Book Notes 2

| operator is used for union operation in Array.
& operator is used for intersection operation in Array.


1: class Array
2: def union(another)
3: self | another
4: end
5: def intersection(another)
6: self & another
7: end
8: end