RbComplex
public struct RbComplex: RbObjectConvertible
A simple interface to Ruby’s complex number support.
This is not a Swift complex number library. It could be used as an interface between one such and Ruby.
Ruby always represents complex numbers internally using rectangular coordinates so this type does not offer any direct support for polar coordinates.
Topics
var real: Double
var real: Double
var imaginary: Double
var imaginary: Double
init(real: Double, imaginary: Double)
init(real: Double, imaginary: Double)
init?(RbObject)
init?(RbObject)
Create a complex number from a Ruby object.
This calls #to_c
before extracting real and imaginary parts so can
be passed various types of Ruby object.
Returns nil
if the object cannot be converted or if its real and
imaginary parts cannot be converted to Swift Double
s.
See RbError.history
to see why a conversion failed.
Declaration
public init?(_ value: RbObject)
init?(any RbObjectConvertible)
init?(any RbObjectConvertible)
Convert some Swift data type to a complex number.
This is a convenience wrapper that lets you access Ruby’s library directly from Swift types, for example:
let compl = RbComplex("1+2.3i")
Declaration
public init?(_ value: any RbObjectConvertible)
var rubyObject: RbObject
var rubyObject: RbObject
Get a Ruby version of an RbComplex
.
This can theoretically produce RbObject.nilObject
if the Complex
class has been nobbled in some way.
Declaration
public var rubyObject: RbObject { get }