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.



410
411
412
413
414
415
416
# File 'lib/carray/basics.rb', line 410

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