Method: T.bind
- Defined in:
- lib/types/_types.rb
.bind(value, type, checked: true) ⇒ Object
Tells the type checker to treat ‘self` in the current block as `type`. Useful for blocks that are captured and executed later with instance_exec. Use like:
seconds = lambda do
T.bind(self, NewBinding)
...
end
‘T.bind` behaves like `T.cast` in that it is assumed to be true statically.
If ‘checked` is true, raises an exception at runtime if the value doesn’t match the type (this is the default).
168 169 170 171 172 |
# File 'lib/types/_types.rb', line 168 def self.bind(value, type, checked: true) return value unless checked Private::Casts.cast(value, type, "T.bind") end |