Skip to content

Commit e56a5ed

Browse files
committed
Update README
1 parent 07c9d07 commit e56a5ed

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
11
# Set
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/set`. To experiment with that code, run `bin/console` for an interactive prompt.
3+
This library provides the Set class, which deals with a collection of
4+
unordered values with no duplicates. It is a hybrid of Array's
5+
intuitive inter-operation facilities and Hash's fast lookup.
46

5-
TODO: Delete this and the text above, and describe your gem
7+
The method `to_set` is added to Enumerable for convenience.
8+
9+
Set implements a collection of unordered values with no duplicates.
10+
This is a hybrid of Array's intuitive inter-operation facilities and
11+
Hash's fast lookup.
12+
13+
Set is easy to use with Enumerable objects (implementing `each`).
14+
Most of the initializer methods and binary operators accept generic
15+
Enumerable objects besides sets and arrays. An Enumerable object can
16+
be converted to Set using the `to_set` method.
17+
18+
Set uses Hash as storage, so you must note the following points:
19+
20+
* Equality of elements is determined according to Object#eql? and
21+
Object#hash. Use Set#compare_by_identity to make a set compare its
22+
elements by their identity.
23+
24+
* Set assumes that the identity of each element does not change while
25+
it is stored. Modifying an element of a set will render the set to
26+
an unreliable state.
27+
28+
* When a string is to be stored, a frozen copy of the string is stored
29+
instead unless the original string is already frozen.
30+
31+
### Comparison
32+
33+
The comparison operators `<`, `>`, `<=`, and `>=` are implemented as
34+
shorthand for the {proper_,}{subset?,superset?} methods. The `<=>`
35+
operator reflects this order, or return `nil` for sets that both have
36+
distinct elements (`{x, y}` vs. `{x, z}` for example).
637

738
## Installation
839

@@ -37,8 +68,6 @@ s2.subset?(s1) #=> true
3768

3869
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
3970

40-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41-
4271
## Contributing
4372

4473
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/set.

0 commit comments

Comments
 (0)