File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -2301,11 +2301,20 @@ condition](#safe-assignment-in-condition).
23012301 ````
23022302
23032303* <a name="no-extend-struct-new"></a>
2304- Don't extend a `Struct.new` - it already is a new class . Extending it
2305- introduces a superfluous class level and may also introduce weird errors if
2306- the file is required multiple times.
2304+ Don't extend an instance initialized by `Struct.new`. Extending it introduces
2305+ a superfluous class level and may also introduce weird errors if the file is
2306+ required multiple times.
23072307<sup>[[link](#no-extend-struct-new)]</sup>
23082308
2309+ ```Ruby
2310+ # bad
2311+ class Person < Struct.new(:first_name, :last_name)
2312+ end
2313+
2314+ # good
2315+ Person = Struct.new(:first_name, :last_name)
2316+ ````
2317+
23092318* <a name="factory-methods"></a>
23102319 Consider adding factory methods to provide additional sensible ways to
23112320 create instances of a particular class.
You can’t perform that action at this time.
0 commit comments