Skip to content

[idea?] Using ternary with array push operator #945

@nerixim

Description

@nerixim

When using ternary with array push operator, the result may surprise you depending on your knowledge of operator precedence.

array = []

# bad
array << true ? 1 : 0
=> 1
# array = [true]

# good (?)
array << (true ? 1 : 0)
# array = [1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions