Using ಠ_ಠ to Throw Exceptions


Most people don’t know that you can oftentimes put Unicode characters in your code. However, the look of disapproval is gold, and I am now going to use it to throw exceptions.

C# version:

        public static void ಠ_ಠ(string error)
        {
            throw new Exception(error);
        }

        public static void CreateFile(string path)
        {
            if(File.Exists(path))
            {
                ಠ_ಠ("error: file exists");
            }

            File.Create(path);
        }

F# version

open System.IO

let ಠ_ಠ = failwith

let createFile path =
    if File.Exists(path) then
        ಠ_ಠ "error: file exists"

    File.Create(path)

Note: This is inspired from a practical joke from some coworkers in the past. Someone apparently snuck in a method named _μ into the code. That is “underscore mu” and apparently it drove people nuts.


19 responses to “Using ಠ_ಠ to Throw Exceptions”

  1. For ruby 1.9

    # encoding: utf-8

    def ಠ_ಠ message
    raise Exception, message, caller
    end

    ಠ_ಠ “file not found”

    look_of_dissaproval.rb:7:in `’: file not found (Exception)

  2. Works in PowerShell, if you’re using a unicode-capable host like PowerShell ISE or PoshConsole

    You can either:

        sal ಠ_ಠ throw

    or:

        function ಠ_ಠ { throw $args }

    In either case:

        ಠ_ಠ "You're wrong"
  3. Works in R :).


    >ಠ_ಠ <- function(x) { stop(as.character(x)) }

    Example:

    > sapply(1:5, function(x) { if (x == 5) ಠ_ಠ(x) })
    Error in ಠ_ಠ(x) : 5

  4. This time with feeling:


    function ಠ_ಠ($error)
    {
    throw new Exception($error);
    }

    try
    {
    ಠ_ಠ("I'm so sorry.");
    }
    catch (Exception $e)
    {
    echo $e->getMessage() . " It won't happen again\n";
    }

  5. Decided to make a jQuery script based on this


    <!DOCTYPE html>
    <html>
    <head>
    <title>The Code Of Disapproval (ಠ_ಠ)</title>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/themes/base/jquery-ui.css&quot; type="text/css" media="all" />
    <style type="text/css">
    #draggable
    {
    width: 150px;
    height: 150px;
    padding: 0.5em;
    }
    </style>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js&quot; type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/jquery-ui.js&quot; type="text/javascript"></script>
    <script type="text/javascript">
    jQuery(document).ready(function (ಠ_ಠ) {
    ಠ_ಠ("#draggable").draggable();
    });
    </script>
    </head>
    <body>
    <div class="demo">
    <div id="draggable" class="ui-widget-content">
    <p>Drag ಠ_ಠ around</p>
    </div>
    </div>
    </body>
    </html>

    view raw

    gistfile1.html

    hosted with ❤ by GitHub

Leave a reply to Mastur B. Cancel reply