+ 1
Can we have multiple initializers for a class
Can we have multiple initializer method for a class. Like over loaded constructors in c++
2 ответов
+ 1
Sadly not, because Ruby doesn't know beforehand which types the arguments gonna have.
You can however create a initializer with the splat operator:
https://code.sololearn.com/cDQ6rKdYeO13/#rb
Or you can give the initializer default arguments:
https://code.sololearn.com/c2zRI2vl8U2J/#rb
0
Thanks alot Jacques.