Skip to content

Guide should cover use of {} around implicit argument hashes #223

@meagar

Description

@meagar

Given this function...

def my_method(user, options = {})
end

All of the following are valid, but which is preferred?

  1. my_method x, name: "John", age: 45
  2. my_method x, { name: "John", age: 45 }
  3. my_method(x, name: "John", age: 45)
  4. my_method(x, { name: "John", age: 45 })

I would typically use 1 for a DSL like validates :name, presence: true (the guide already makes allowances for omitting () for DSLs) and 3 for other Ruby code.

Can the guide be updated to explicitly address this question?

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