Skip to content

Linked List order #1743

@NeimadTL

Description

@NeimadTL

Hi,

I was working on the simple linked list exercise and I couldn't help to wonder whether this assertion, which reads:

  def test_list_multiple_to_array
    skip
    list = SimpleLinkedList.new
    first = Element.new(1)
    second = Element.new(2)
    third = Element.new(3)
    list.push(first).push(second).push(third)
    assert_equal [3, 2, 1], list.to_a
  end

was correct?

In my opinion, when adding an element to the list with the following code:

list = SimpleLinkedList.new
first = Element.new(1)
second = Element.new(2)
third = Element.new(3)
list.push(first).push(second).push(third)

I should get that :
=> [1, 2, 3]

in other word the assertion should be this:
assert_equal [1, 2, 3], list.to_a

I haven't finished the exercise yet but I'm curious to get your opinion on it. Thank you.

Conversation on the forums located here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions