Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Aliasing operators possible?

Reply
Thread Tools

Aliasing operators possible?

 
 
GGarramuno
Guest
Posts: n/a
 
      12-31-2003
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=~ :=~
^
 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      01-01-2004
On Wed, 31 Dec 2003 15:48:42 -0800, GGarramuno wrote:

> SyntaxError: compile error
> (irb):2: syntax error
> alias ld=~ :=~
> ^


"old=~" isn't a legal method name. Try

alias ld_match :=~

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
aliasing palmis Java 0 02-02-2006 08:32 PM
More anti-aliasing puzzles Roedy Green Java 25 08-16-2005 07:41 PM
Aliasing a class name? Wesley T Perkins Java 8 07-01-2005 01:56 AM
Anti-aliasing GIF Images Kevin Bertman Java 4 11-29-2004 05:46 AM
LCD anti-aliasing in Java Tim Tyler Java 2 09-05-2003 09:01 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57