struct Ok(T)
Overview
Result
Ok.
Defined in:
result.crConstructors
-
.[](value) : Ok
Syntax sugar for
Ok.done(value)
. -
.created(value) : Ok
Creates a new
Ok
instance with the status:created
. -
.destroyed(value) : Ok
Creates a new
Ok
instance with the status:destroyed
. -
.done(value) : Ok
Creates a new
Ok
instance with the status:done
. - .new(status : Symbol, value : T)
- .new(value : T)
-
.pending(value) : Ok
Creates a new
Ok
instance with the status:pending
. -
.updated(value) : Ok
Creates a new
Ok
instance with the status:updated
.
Class Method Summary
-
.type : Symbol
Result
type as aSymbol
.
Instance Method Summary
-
#status : Symbol
Result
status as aSymbol
(:done or :fail, etc). -
#type : Symbol
Result
type as aSymbol
. -
#unwrap
Unwrap the result
#value
(like Result::unwrap in Rust). -
#value : T
Returns the result value.
Instance methods inherited from struct Result(T)
err? : Bool
err?,
initialize
initialize,
ok? : Bool
ok?,
state : Tuple(Symbol, Symbol, T)
state,
status : Symbol
status,
status?(s : Symbol) : Bool
status?,
type : Symbol
type,
unwrap
unwrap,
value : T
value
Constructor methods inherited from struct Result(T)
new
new
Class methods inherited from struct Result(T)
err? : Bool
err?,
ok? : Bool
ok?
Constructor Detail
Syntax sugar for Ok.done(value)
.
Ok["hello"] # => same as Ok.done("hello")
Creates a new Ok
instance with the status :created
.
This method is a shortcut for Ok.new :created, value
.
res = Ok.created(value)
res.status # => :created
pp res.unwrap
# or
pp res.value
Creates a new Ok
instance with the status :destroyed
.
This method is a shortcut for Ok.new :destroyed, value
.
res = Ok.destroyed(value)
res.status # => :destroyed
pp res.unwrap
# or
pp res.value
Creates a new Ok
instance with the status :done
.
This method is a shortcut for Ok.new :done, value
.
res = Ok.done(value)
res.status # => :done
pp res.unwrap
# or
pp res.value
Creates a new Ok
instance with the status :pending
.
This method is a shortcut for Ok.new :pending, value
.
res = Ok.pending(value)
res.status # => :pending
pp res.unwrap
# or
pp res.value
Creates a new Ok
instance with the status :updated
.
This method is a shortcut for Ok.new :updated, value
.
res = Ok.updated(value)
res.status # => :updated
pp res.unwrap
# or
pp res.value