From the Rspec doco, I found one code :-
class ArrayWithOneElement < Array
unshift “first element”
#initialize method will never throw argument error as greedy
swallow whatever you will give it. And if you don’t give it anything, it
wouldn’t cry also.
My question is what is the advantage of this pattern of method
signature ? While I don’t need any argument while instantiating a class,
could define it,
If I need argument at the time of instantiation, I will mention it
def initialize(arg1,arg2) # whatever pattern fits
But why this greedy approach, while I wouldn’t be able to access it
the argument what may be passed or not ?
Can anyone highlight me on this ?
Debugging is twice as hard as writing the code in the first place.
if you write the code as cleverly as possible, you are, by definition,
smart enough to debug it.