Skip to content

Commit 4f178e0

Browse files
committed
Add section about long &. chains
1 parent e66a93a commit 4f178e0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.adoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,20 @@ class User
351351
end
352352
user&.zip
353353
----
354+
355+
=== Long safe navigation chain [[long-safe-navigation-chain]]
356+
357+
Avoid `&.` chains longer than two.
358+
359+
[source,ruby]
360+
----
361+
# bad
362+
user&.address&.zip
363+
364+
# good
365+
user.address.zip if user
366+
----
367+
354368
=== Spaces and Braces [[spaces-braces]]
355369

356370
No spaces after `(`, `[` or before `]`, `)`.

0 commit comments

Comments
 (0)