Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/carray/basics.rb

Overview


Container -> CArray coercion (relocated from former basic.rb)

Instance Method Summary collapse

Instance Method Details

#to_ca(writable: false) ⇒ CArray

Returns self coerced into a CA_OBJECT CArray of matching shape.

The result is a freshly built array that shares nothing with the receiver, so writable: true — a demand for a result whose writes reach the source — is refused.

Returns:

Raises:

  • (RuntimeError)

    when writable: true is given.



406
407
408
409
410
411
412
# File 'lib/carray/basics.rb', line 406

def to_ca(writable: false)
  if writable
    raise "#{self.class}#to_ca builds a new array; " \
          "it can't satisfy `writable: true'"
  end
  return CA_OBJECT(self)
end