ElixirのEnumerable 前回の記事から続いて、今回はElixirで利用する基本的な制御構文について学んでいきます。 Keyword list 多くの関数型プログラム言語では、2要素のtupleによって関連付けられたデータ構造を表現します。 Elixirでは、最初の要素がAtomであるTupleのListのことをKeyword listと呼びます。 iex> list = [{:a, 1}, {:b, 2}] [a: 1, b: 2] iex> list == [a: 1, b: 2] true iex> list[:a] 1 キーが重複している場合、先頭に格納された値が優先的に読まれます。 iex> new_list = [a: 0] ++ list [a: 0, a: 1, b: 2] iex> new_list[:a] 0 Keyword listは以下の重要な性質を持ちま
View Source Basic types In this chapter we will learn more about Elixir basic types: integers, floats, booleans, atoms, and strings. Other data types, such as lists and tuples, will be explored in the next chapter. iex> 1 # integer iex> 0x1F # integer iex> 1.0 # float iex> true # boolean iex> :atom # atom / symbol iex> "elixir" # string iex> [1, 2, 3] # list iex> {1, 2, 3} # tuple Basic arithmetic
Settings View Source Keyword lists and maps Now let's talk about associative data structures. Associative data structures are able to associate a key to a certain value. Different languages call these different names like dictionaries, hashes, associative arrays, etc. In Elixir, we have two main associative data structures: keyword lists and maps. Keyword lists Keyword lists are a data-structure u
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く