multipart-message nevyn bengtsson's blog

featured articles 🦄, about, archive, tags

Mr. Random Is My Friend

This is Mr. Random.

21:35:26 nevyn@xephon:~$ cat bin/rnd
  #!/usr/bin/env ruby
  class Array
    def random
      self[Kernel.rand(self.length)]
    end
  end


  if $0 == __FILE__
    puts $*.random
  end

This is how you use Mr. Random.

21:38:38 nevyn@xephon:~$ rnd pizza chinese leftovers
leftovers 

The best thing is how it makes you realize what you don’t want.

21:38:50 nevyn@xephon:~$ rnd pizza
pizza 

Tagged coding, faves