# Special UTF8 characters as methods in ruby

**URL:** <https://www.ruby-forum.com/t/special-utf8-characters-as-methods-in-ruby/153080>\
**Category:** Ruby\
**Created:** [November 11, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/special-utf8-characters-as-methods-in-ruby/153080 "2008-11-11T23:11:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![six](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a6a055/32.png) [@six](https://www.ruby-forum.com/u/six)\
**Post date:** [November 11, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/special-utf8-characters-as-methods-in-ruby/153080/1 "2008-11-11T23:11:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![six](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a6a055/32.png) [@six](https://www.ruby-forum.com/u/six)\
**Post date:** [November 11, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/special-utf8-characters-as-methods-in-ruby/153080/2 "2008-11-11T23:35:51Z")

</div>

Nevermind, figured it out.

Note to self:

$KCODE = “UTF-8”  
ruby -Ku script\_with\_funky\_chars

Pardon the bother.
