Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
MIT-License.txt
README.md
collection.gemspec
init.rb
install-gems.sh
library-symlinks.sh
load_path.rb
remove-lib-symlinks.sh
symlink-lib.sh

README.md

collection

Type-checked set

Example

type = String

collection = Collection::Set.new(type)

collection.add('something')

collection.entry? { |v| v == 'something' }
# => true

collection.entry?('something')
# => true

collection.add(:not_a_string)
# => ArgumentError (:not_a_string must be a String)

Generic-Style

type = String

cls = Collection::Set[type]

cls
# => "Collection::Set::String"

collection = cls.new

collection.add('something')

collection.entry? { |v| v == 'something' }
# => true

collection.entry?('something')
# => true

collection.add(:not_a_string)
# => ArgumentError (:not_a_string must be a String)

Factory Method

things = ['Thing 1', 'Thing 2']

collection = Collection::Set(things)

collection.entry? { |v| v == 'Thing 1' }
# => true

collection.entry?('Thing 1')
# => true

collection.add(:not_a_string)
# => ArgumentError (:not_a_string must be a String)

License

The collection library is released under the MIT License.

You can’t perform that action at this time.