---
title: "Unicode symbols as function names"
description: "Unicode stings for function/method names is a very rare scenario, but who knows in the near future people might use them."
url: "https://h3manth.com/scribe/unicode-symbols-as-function-names/"
canonical_url: "https://h3manth.com/scribe/unicode-symbols-as-function-names/"
markdown_url: "https://h3manth.com/scribe/blog/unicode-symbols-as-function-names.md"
publishDate: "2011-11-30T00:00:00.000Z"
author: "Hemanth HM"
category: "javascript"
tags: ["javascript","python","ruby"]
word_count: 317
reading_time_minutes: 2
x_markdown_tokens: 492
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Unicode symbols as function names

> Unicode stings for function/method names is a very rare scenario, but who knows in the near future people might use them.

Unicode stings for function/method names is a very rare scenario, but who knows in the near future people might use them daily! [ Too much of an expectation aye? ;) ]

Say : one needs to convert dollars to pounds and writes a method to do so, might name it "dollar2pound", but a code monkey might name it **$2£**

*Below is the result of such a play in few of my favorite programming languages :*

To makes things silly/simple, lets assume our methods takes an integer argument and prints ❤'s those many time.

**First up is BASH  [ Simple, undocumented so might stop working soon! ]:**

```javascript
function ❤ () { yes '❤' | head -n$1 | xargs echo; }
```

## Invoke the function
❤ 12

## Bazinga! we got 12 ❤s :)
❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
```

```

** Python's turn : **

```javascript
l={} 
l['❤'] = lambda x: "❤ "*x
print l['❤'](12).decode('utf8')
❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
```

```

** Perl! here it comes! [ Yes you are right, no strict ] : **

```php
```javascript
use utf8;
*{'❤'} = sub { print '❤ ' x shift; }; 
${\'❤'}->(12);  
❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
```

```

** Ruby  [ Don't forget -Ku ] : **

```ruby
#!/usr/bin/ruby -Ku
def ❤(x)
    puts '❤ '*x;
end
❤(12)
❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
```

```

** JavaScript FTW!? ** 

```javascript
String.prototype.repeat = function(n) { 
return (new Array(n+1)).join(this.valueOf()); 
};
this["❤"] = function (x) { return '❤ '.repeat(x); }; 
this["❤"](12)
❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
```

Update : 

```javascript
function Σ() {return [].reduce.call(arguments, function(a,b){return a+b})};
 
Σ(1,2,3,4)

10

* So how do you do it in your fav programming languages ;) ? *

```
