📜 ⬆️ ⬇️

Emoticon Programming

image

In honor of today's bright day I publish this article. After all, you also sometimes think that the code consists of emoticons?

Ruby


Determination of the default or facial expression lips:
foo ||= [] foo ||= {} foo ||= '' foo ||= 0 


Jumping toads out of the wash out heme:
 def_delegators :@config, :[], :[]=, :sort 

')
From there, code generation, cyclo eats a variable:
 @#{sym} 


Calling the class as a hash or array, again a toad:
 alias_method :regular_writer, :[]= unless method_defined?(:regular_writer) 


govnokod.ru/2749
 map(&:-@) 

Seem to be?
image

Toad with turban in the ternary operator.
 var.is_a Array ? {} : [] 


Another Ruby monster, applying the 'or' and 'and' operator to all elements of the flags with the help of poker face and lip rolling.
 flags.reduce(&:|) flags.reduce(&:&) 


We need to make a terrible face if we are not sure that the hash has an embedded hash:
 session[:comments].try(:[], @comment.id) 


bash



Command line parameters also completely disappear for smiles:

Every time it seems to me that this is such a wide apologetic smile, saying “I forgot what tasks there are, please bring out the list”:
 rake -D 


CoffeeScript



Complete panic when mixing Coffee and jQuery
 $(@) 

image

CoffeeScript makes smiles easy
 foo = bar getBar:-> @bar #    Coffee not:(o)-> !o 


Slim


 =< "Hello!" => "Hello!" =<> "Hello!" 


Php


It's sad when the array ends:
 $var = array( 1 => 'one' ); 


And even sadder when it ends with the transfer of attributes:
 $var = some_function(array( 'named_attr' => 'one' )); 


Everywhere and everywhere


There are many places where you can pass an empty string to a function:
 ('') ("") [''] [""] 

With this you can dream up, but when this came across, it was quickly recognized as a Papuan priest (because with a native belt at the waist):
 ('.') 

And here is a sleeping owl:
 [","] 


Skype, by the way, sometimes sees smilies too. Log forwarding:

image

PS


Send your pieces of code in the comments, I hope, today we will put together a nice collection.

upd:


Apparently, on this holiday thoughts converge:
Factorial on Church numbers - now in emoticons

Source: https://habr.com/ru/post/184278/


All Articles