Method: Functional::Tuple#initialize

Defined in:
lib/functional/tuple.rb

#initialize(data = []) ⇒ Tuple

Create a new tuple with the given data items in the given order.

Parameters:

  • data (Array) (defaults to: [])

    the data items to insert into the new tuple

Raises:

  • (ArgumentError)

    if data is not an array or does not implement ‘to_a`



38
39
40
41
42
43
44
# File 'lib/functional/tuple.rb', line 38

def initialize(data = [])
  raise ArgumentError.new('data is not an array') unless data.respond_to?(:to_a)
  super
  @data = data.to_a.dup.freeze
  self.freeze
  ensure_ivar_visibility!
end