Method: Immutable::List#append

Defined in:
lib/immutable/list.rb

#append(other) ⇒ List Also known as: concat, +

Return a List with all items from this List, followed by all items from other.

Examples:

Immutable::List[1, 2, 3].append(Immutable::List[4, 5])
# => Immutable::List[1, 2, 3, 4, 5]

Parameters:

  • other (List)

    The list to add onto the end of this one

Returns:



377
378
379
380
381
382
# File 'lib/immutable/list.rb', line 377

def append(other)
  LazyList.new do
    next other if empty?
    Cons.new(head, tail.append(other))
  end
end