RbBreak

Swift
public struct RbBreak: Error

Throwing an instance of this type terminates and gives an overall result to a Ruby block-based iteration like the Ruby break keyword.

let result = myobj.call("each") { args in
                 let derived = f(args[0])
                 if g(derived) {
                     throw RbBreak(with: derived)
                 }
                 return .nilObject
             }

Topics

init(with: RbObjectConvertible?)

Create an object to break out from a Ruby iterator.

Declaration
Swift
public init(with object: RbObjectConvertible? = nil)
Parameters
object

the value to give as the result of the iteration. Default nil equivalent to raw break in Ruby.