July 11, 2017
Let's look at the documentation of length
function of String
in Elm.
It's here and it looks like this.
length : String -> Int
> String.length "Hello World"
11 : Int
If we look at the similar feature in Ruby world then we get length method.
length -> integer
Methos signature in ruby's documentation and Elm's documentation is quite similar. Both return an integer.
In Elm's world method definitions are called "Type Annotations". Going forward that's what I'm going to use in this blog.
Now let's look at method definition of slice
method in Ruby.
It looks like this.
slice(start, length) -> new_str or nil
irb(main):006:0> "snakes on a plane!".slice(0,6)
=> "snakes"
In Elm world it looks like this.
slice : Int -> Int -> String -> String
> String.slice 0 6 "snakes on a plane!"
"snakes" : String
Questions is what's up with all those arrows.
If this blog was helpful, check out our full blog archive.