Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Elixir won't allow you to do that:

   iex(2)> "/home/cess11" * 9
   ** (ArithmeticError) bad argument in arithmetic expression: "/home/cess11" * 9
       :erlang.*("/home/cess11", 9)
       iex:2: (file)
Documentation is full of type information:

https://hexdocs.pm/elixir/Enum.html#types



I think their point is that Elixir lets you write

    defmodule Multiply do
      def m9(m1), do: m1 * 9
    end

    # elsewhere...
    defmodule Caller do
      def doit() do
        Multiply.m9(2)
        Multiply.m9("hi")
      end
    end
It won't raise an exception or give you a warning while compiling it (tested with 1.18.4). Even adding

    @spec m9(integer()) :: integer()
above its definition doesn't do anything.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: