module T
def self.must(arg)
to contain a non-nil value at this point.
Intended to be used to promise sorbet that a given nilable value happens
needs_foo(foo)
raise "nil" if foo.nil?
foo = maybe_gives_foo
Equivalent to:
needs_foo(T.must(maybe_gives_foo))
Intended to be used as:
otherwise.
A convenience method to `raise` when the argument is `nil` and return it
def self.must(arg) return arg if arg return arg if arg == false begin raise TypeError.new("Passed `nil` into T.must") rescue TypeError => e # raise into rescue to ensure e.backtrace is populated T::Configuration.inline_type_error_handler(e, {kind: 'T.must', value: arg, type: nil}) end end