Method: Highway::Steps::Types::Array#typecheck
- Defined in:
- lib/highway/steps/types/array.rb
permalink #typecheck(value) ⇒ Array?
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.
34 35 36 37 38 |
# File 'lib/highway/steps/types/array.rb', line 34 def typecheck(value) return nil unless value.kind_of?(::Array) typechecked = value.map { |element| @element_type.typecheck_and_validate(element) } typechecked if typechecked.all? { |element| !element.nil? } end |