DRYな備忘録

Don't Repeat Yourself.

2016-02-07から1日間の記事一覧

ElixirでFizzBuzz

前回まで 【Elixir】バージョン管理しつつErlangとElixirをMacにインストールする - DRYな備忘録 【Elixir】the result of the expression is ignored - DRYな備忘録 【Elixir】use of operator === has no effect と言われる - DRYな備忘録 Elixirでゼロ埋…

Elixirでゼロ埋め【zero padding】【elixir】

iex(6)> String.rjust("hoge", 8, ?0) "0000hoge" zero paddingしたい対象がintegerなら、適宜、第1Integer.to_striingなど使う。 123 |> Integer.to_string |> String.rjust(8, ?0) 参考 In Elixir, how do you format numbers with string interpolation -…

【Elixir】use of operator === has no effect と言われる

問題 Elixirのコンパイラに掲題のように叱られる。 原因 「===使ってもええんやで」という意味。 解決 1..max |> Enum.each fn(n) -> - case {rem(n, 3) == 0, rem(n, 5) == 0} do + case {rem(n, 3) === 0, rem(n, 5) === 0} do {true, true} -> 雑感 たと…

【Elixir】the result of the expression is ignored

問題 ElixirでFizzBuzz書いてて、掲題のように怒られる main.exs:4: warning: the result of the expression is ignored (suppress the warning by assigning the expression to the _ variable) the result of the expression is ignored (suppress the war…