Ruby, etc

Learn all the things

He who enjoys doing and enjoys what he has done is happy. - Fortune Cookie

One-Liners in Clojure and Ruby

A quick post to start off the new year.

You and your co-workers can’t decide where to go for lunch?

1
2
 ruby -e "puts [:tacos, :chicken, :bbq].sample"
chicken
1
2
 clj -e "(rand-nth [:tacos :chicken :bbq])"
:tacos

Observations:

Ruby I had to tell it what to do with the output, to puts it. It didn’t automatically display like if I had done that line in the irb repl. Oh and don’t do what I did at first and forget the , (comma) :)

Clojure, since everything returns a value, I just had to call the function.

Have fun using code to make important decisions, like .. Lunch :)

Comments