ブログから転載 Elixir 1.3(正確には1.3.0-rc.0)から時間に関する構造体がいくつか定義されました。そのうちの3つ、Date, Time, NaiveDateTimeをつくるsigilが追加されています。それぞれ~D, ~T, ~Nです。 iexで~D(2016-06-04)と打っても、そのまま表示されてしまい何が作られているのかよくわからないので、|> inspect(structs: false)としています iex> ~D(2016-06-04) |> inspect(structs: false) "%{__struct__: Date, calendar: Calendar.ISO, day: 4, month: 6, year: 2016}" iex> ~T(22:05:33) |> inspect(structs: false) "%{__struct__:
Elixirには、Rubyなどの言語に見られるような %w(...) という記法が存在する。Elixirのドキュメントではそれを「Sigil」と呼んでいる。 ドキュメントにある通り以下の4つがデフォルトで定義済み。 %c and %C - Returns a char list; %r and %R - Returns a regular expression; %s and %S - Returns a string; %w and %W - Returns a list of "words" split by whitespace; また、Rubyの同様の表記と違い、接尾辞を指定できる。「modifier」と呼ばれる。無いものを指定すると例外。 %w(foo bar 123)a #=> [:foo, :bar, :"123"] %w(foo bar 123)z # ** (Argume
In computer programming, a sigil (/ˈsɪdʒəl/) is a symbol affixed to a variable name, showing the variable's datatype or scope, usually a prefix, as in $foo, where $ is the sigil. Sigil, from the Latin sigillum, meaning a "little sign", means a sign or image supposedly having magical power.[1] Sigils can be used to separate and demarcate namespaces that possess different properties or behaviors. Hi
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く