Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rules for hexadecimal, binary and decimal literal prefixes #579

Merged
merged 1 commit into from
Jun 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,26 @@ Translations of the guide are available in the following languages:
num = 1_000_000
```

* <a name="octal-literals"></a>
Use `0o` for octal literals instead of `0` or `0O`.
<sup>[[link](#octal-literals)]</sup>
* <a name="numeric-literal-prefixes"></a>
Prefer smallcase letters for numeric literal prefixes.
`0o` for octal, `0x` for hexadecimal and `0b` for binary.
Do not use `0d` prefix for decimal literals.
<sup>[[link](#numeric-literal-prefixes)]</sup>

```Ruby
# bad
num = 01234

# bad - hard to differentiate zero and big-O
num = 0O1234
num = 0X12AB
num = 0B10101
num = 0D1234
num = 0d1234

# good - easier to separate digits from the prefix
num = 0o1234
num = 0x12AB
num = 0b10101
num = 1234
```

* <a name="rdoc-conventions"></a>
Expand Down