Skip to content

Add guidance for safe navigation operator (&.) #889

Closed
@andyw8

Description

@andyw8

Reading https://thoughtbot.com/blog/ruby-safe-navigation reminded me that over-use of &. is common. I think it would be helpful to add a guideline such as:

Avoid long chains of &.. Replace with . if they introduce unnecessary conditional logic. Consider other approaches such as delegation.

This could also be added as a rule in RuboCop with a maximum number of chained calls (e.g. 2 or 3).

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