T
Trans
I've been thinking about the last thread on module methods and
namespaces, and also the idea of method modifiers. There are times when
I just want one method that does a number of different but related
things. Th obligatory silly example,
class T
def dothis(sym, *args)
when neway
puts "One Way! #{args}"
when :another
puts "Another! #{args}"
end
end
end
t = T.new
t.dothis neway
But we can also do this without the space,
t.dothis:another
IMO that's nice. And allows me to get the effect that I want. What
would be even more convenient thgouh is if this later form, lacking the
space, would give the method precedence, so we could do,
t.dothis:another.upcase
and it would work, executing #dothis before #upcase. Then, also,
secondary parameters could be given without the initial comma. So,
t.dothis neway, 1
could instead be written,
t.dothisneway 1
I do not think this would present any ambiguity to the parser. In fact
I thnk it can be take to any number of initial symbols.
t.dothisneway:twoway:threeway
Where each subsequent symbol is another argument.
T
namespaces, and also the idea of method modifiers. There are times when
I just want one method that does a number of different but related
things. Th obligatory silly example,
class T
def dothis(sym, *args)
when neway
puts "One Way! #{args}"
when :another
puts "Another! #{args}"
end
end
end
t = T.new
t.dothis neway
But we can also do this without the space,
t.dothis:another
IMO that's nice. And allows me to get the effect that I want. What
would be even more convenient thgouh is if this later form, lacking the
space, would give the method precedence, so we could do,
t.dothis:another.upcase
and it would work, executing #dothis before #upcase. Then, also,
secondary parameters could be given without the initial comma. So,
t.dothis neway, 1
could instead be written,
t.dothisneway 1
I do not think this would present any ambiguity to the parser. In fact
I thnk it can be take to any number of initial symbols.
t.dothisneway:twoway:threeway
Where each subsequent symbol is another argument.
T