method

sole

Importance_1
v7.1.3.2 - Show latest stable - 0 notes - Class: Enumerable
sole() public

Returns the sole item in the enumerable. If there are no items, or more than one item, raises +Enumerable::SoleItemExpectedError+.

["x"].sole          # => "x"
Set.new.sole        # => Enumerable::SoleItemExpectedError: no item found
{ a: 1, b: 2 }.sole # => Enumerable::SoleItemExpectedError: multiple items found
Show source
Register or log in to add new notes.