Method: Highway::Steps::Types::Set#typecheck

Defined in:
lib/highway/steps/types/set.rb

#typecheck(value) ⇒ Set?

Typecheck and coerce a value if possible.

This method returns a typechecked and coerced value or nil if value has invalid type and can’t be coerced.

Parameters:

  • value (Object)

    A value.

Returns:



28
29
30
31
32
33
# File 'lib/highway/steps/types/set.rb', line 28

def typecheck(value)
  typechecked_array = super(value)
  return nil if typechecked_array == nil
  typechecked_set = ::Set.new(typechecked_array)
  typechecked_set if typechecked_set.count == typechecked_array.count
end