Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

No description, website, or topics provided.

Resources

License

Releases

No releases published

Packages

No packages published