G
GGarramuno
I'd like to alias the =~ operator, is this possible?
This is what I'm doing and what I get:
Normal aliasing of a method (all fine):
irb(main):015:0> class String
irb(main):016:1> alias ldsub :sub
irb(main):017:1> def sub(a,b)
irb(main):018:2> p "sub"
irb(main):019:2> oldsub(a,b)
irb(main):020:2> end
irb(main):021:1> end
irb(main):027:0>"abc".sub(/a/,"")
"sub"
=> "bc"
------------------------------------------
Aliasing of =~ (not fine)
irb(main):001:0> class String
irb(main):002:1> alias ld=~ :=~
irb(main):003:1> def =~(pat)
irb(main):004:2> p "new"
irb(main):005:2> old=~(pat)
irb(main):006:2> end
irb(main):007:1> end
SyntaxError: compile error
(irb):2: syntax error
alias ld=~ :=~
^
This is what I'm doing and what I get:
Normal aliasing of a method (all fine):
irb(main):015:0> class String
irb(main):016:1> alias ldsub :sub
irb(main):017:1> def sub(a,b)
irb(main):018:2> p "sub"
irb(main):019:2> oldsub(a,b)
irb(main):020:2> end
irb(main):021:1> end
irb(main):027:0>"abc".sub(/a/,"")
"sub"
=> "bc"
------------------------------------------
Aliasing of =~ (not fine)
irb(main):001:0> class String
irb(main):002:1> alias ld=~ :=~
irb(main):003:1> def =~(pat)
irb(main):004:2> p "new"
irb(main):005:2> old=~(pat)
irb(main):006:2> end
irb(main):007:1> end
SyntaxError: compile error
(irb):2: syntax error
alias ld=~ :=~
^