Logo

Programming-Idioms

History of Idiom 73 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-08-22, 10:19:33

Version 9

2015-09-03, 17:02:38

Idiom #73 Create a factory

Create a factory named pFact for any sub class of Parent and taking exactly one string str as constructor parameter.

Idiom #73 Create a factory

Create a factory named pFact for any sub class of Parent and taking exactly one string str as constructor parameter.

Code
def p_fact(klass, str)
  klass.new(str) if klass.is_a?(Parent)
end