Dans ce long article de Peter Cooper vous retrouverez quelques basiques qui ont l’avantage d’être à peu près tous regroupés ici et qu’il est toujours bon de revoir
1 - Extract regular expression matches quickly
2 - Shortcut for Array#join
3 - Format decimal amounts quickly
4 - Interpolate text quickly
5 - Delete trees of files
6 - Exploding enumerables
7 - Cut down on local variable definitions
8 - Using non-strings or symbols as hash keys
9 - Use ‘and’ and ‘or’ to group operations for single liners
10 - Do something only if the code is being implicitly run, not required
11 - Quick mass assignments
12 - Use ranges instead of complex comparisons for numbers
13 - Use enumerations to cut down repetitive code
14 - The Ternary Operator
15 - Nested Ternary Operators
16 - Fight redundancy with Ruby’s “logic” features
17 - See the whole of an exception’s backtrace
18 - Allow both single items AND arrays to be enumerated against
19 - Rescue blocks don’t need to be tied to a ‘begin’
20 - Block comments
21 - Rescue to the rescue
N’oubliez pas de lire les commentaires qui sont au moins aussi intéressants que le post lui-même (et qui donnent d’autres exemples) !
Commentaires récents