Fun with Unicode Math in Ruby √

So we started having some fun with Ruby yesterday:

# Get the square root of 5
√ 5  #  => 2.23606797749979 

# or see if infinity + 1 is still in the infinite range
(-∞..∞).cover? ∞ + 1  # => true

# or get the sine of pi / 2
∿ π/2  # => 1.0

# or do math with fractions
⅞ * ⅔ # => 0.5833333333333333

Now you can do all of this and more with the unicode_math gem!

Simply install the gem and you’re off and running.

gem install unicode_math

Check out the source code on GitHub. We’d love to see your ideas for more fun, so get those pull requests coming!

Finally, why would we do this‽ Because it was fun, and Ruby has great support for unicode. Enjoy!

Photo of Daniel Morrison

Daniel founded Collective Idea in 2005 to put a name to his growing and already full-time freelance work. He works hard writing code, teaching, and mentoring.

Comments

  1. October 16, 2012 at 16:39 PM

    Very fun, I picked a great day to stop by the office, and to see the geekery unfold!

  2. May 01, 2013 at 1:33 AM

    シャネルは、フランスでシャネル帝国を作成したクラスと洗練された女性だった

  3. Henry Palmer
    August 10, 2019 at 17:01 PM

    I love to geek out on this stuff!
    Window Tinting Sarasota