[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Special UTF8 characters as methods in ruby

John

11/11/2008 10:05:00 PM


I'm trying to figure out how to define as a method a special math
symbol:

def v num # Not seeing the square root symbol after def here?
Wouldn't surprise me.
Math.sqrt num
end

-- but ruby gives me the error:
:3: Invalid char `\342' in expression
:3: Invalid char `\210' in expression
:3: Invalid char `\232' in expression
Program exited.

I know there is a way to do this and I've looked for a couple days but
can't seem to re-find it. Anyone ever gotten this to work; if so, how?
1 Answer

John

11/11/2008 10:34:00 PM

0

Nevermind, figured it out.

Note to self:

$KCODE = "UTF-8"
ruby -Ku script_with_funky_chars

Pardon the bother.

On Nov 11, 12:05 pm, Six <john.d.perk...@gmail.com> wrote:
> I'm trying to figure out how to define as a method a special math
> symbol:
>
> def  – num  # Not seeing the square root symbol after def here?
> Wouldn't surprise me.
>   Math.sqrt num
> end
>
> -- but ruby gives me the error:
> :3: Invalid char `\342' in expression
> :3: Invalid char `\210' in expression
> :3: Invalid char `\232' in expression
> Program exited.
>
> I know there is a way to do this and I've looked for a couple days but
> can't seem to re-find it. Anyone ever gotten this to work; if so, how?