Method: Faulty::Result#or_default
- Defined in:
- lib/faulty/result.rb
#or_default(default = nil) { ... } ⇒ Object
Get the ok value if this result is ok, otherwise return a default
128 129 130 131 132 133 134 135 136 |
# File 'lib/faulty/result.rb', line 128 def or_default(default = nil) if ok_unchecked? @ok elsif block_given? yield @error else default end end |