Knowthen course 0.18

I’m following the knowthen course for elm, but it’s in 0.18 and somethings have changed. I’ve been able to figure out most of the changes on my own, but can’t seem to get this working. This is the original code from the course elm/first-app-improved at master · knowthen/elm · GitHub and I was able to fix everything except this part:

Input val ->
            case String.toInt val of
                Ok input ->
                    { model
                        | input = input
                        , error = Nothing
                    }

                Err err ->
                    { model
                        | input = 0
                        , error = Just err
                    }

Hi!
String.toInt used to return a Result String Int but now returns a Maybe Int, so you just need to adapt the pattern matching to that:

        Input val ->
            case String.toInt val of
                Just input ->
                    { model
                        | input = input
                        , error = Nothing
                    }

                Nothing ->
                    { model
                        | input = 0
                        , error = Just "Could not convert string to Int"
                    }

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.