Skip to content

Nested Collections: "immutable" arrays ... #30186

@oz123

Description

@oz123

Checks

Describe your suggestion

I am not sure that the example is doing a good use of the term immutable. They example:

immutable = Array.new(3) { Array.new(2) }

Creates and array which we clearly can change:

irb(main):011> immutable[0][0] = 1000
=> 1000
irb(main):012> immutable << "new element"
=> [[1000, nil], [nil, nil], [nil, nil], "new element"]

It might not bother new students of programming, but it does look strange if you already are
coming from a different language ...

I believe that a more accurate description can be used here. For example:

An array with references to different objects

Path

Ruby / Rails

Lesson Url

https://www.theodinproject.com/lessons/ruby-nested-collections

(Optional) Discord Name

No response

(Optional) Additional Comments

Thank you for creating this project!

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