Special UTF8 characters as methods in ruby

S

Six

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?
 
S

Six

Nevermind, figured it out.

Note to self:

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

Pardon the bother.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top