2010/1/26 Zhenning G. [email protected]:
def ss(s = ‘hello’, yeah = nil)
puts “other thing”
#code continue …
What do you need argument “s” for?
what should I do?
Define two methods. At least from the interface this is cleaner.
Generally flags that control method behavior are considered bad
practice because they tend to make the implementation of a method more
complex and tie things together that might really be independent (just
consider what happens if you inherit a class and want to change only
one of the two variants).
Note, you can still share an internal implementation under the hood e.g.
ss_impl “other thing”
But your example is really a bit short to come up with a definitive
answer how to improve this.