Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Dict in Elm for testing?

Tags:

elm

To create a list in elm you can do:

list = ["test","test2"]

But how can I create a Dict for testing purposes?

I've read Dict - core 3.0.0.

like image 624
Stanko Avatar asked Dec 08 '15 11:12

Stanko


1 Answers

let dict = Dict.fromList [("key1", "value1"), ("key2", "value2")]

To insert an element: let dict' = Dict.insert "key3" "value3" dict

To look up an element:

case Dict.get "key1" dict of
  Just value -> ... -- do something with value
  Nothing -> ... -- no such value in dict
like image 66
Philip Kamenarsky Avatar answered Dec 08 '22 00:12

Philip Kamenarsky