Hacker News new | ask | show | jobs
by joevandyk 729 days ago
or pattern match it:

   defmodule Guess do
      def guess_message(candidate, _count=0) do
        "There are no #{candidate}s"
      end

      def guess_message(candidate, _count=1) do
        "There is 1 #{candidate}"
      end

      def guess_message(candidate, count) do
        "There are #{count} #{candidate}s"
      end
    end