Method: Liste#push

Defined in:
lib/prct06/list.rb

#push(obj) ⇒ string

Pushes a new Object at the end of the list.

Parameters:

  • obj (object)
    Object that should be placed at the end of the list.

Returns:

  • (string)
    Returns the String of the Object


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/prct06/list.rb', line 40

def push(obj)
  a = Node.new(obj, nil, @tail)
  if size > 0
    @tail.next = a
  else
    @head = a
  end
  @tail = a
  @size += 1
  return a.value.to_s
end