« Back to channel list

#elixir-lang - 19 April 2019

« Back 1 day Forward 1 day »
[00:08:05] gvaughn: has joined #elixir-lang
[00:13:17] atk: has joined #elixir-lang
[00:16:13] pera: has joined #elixir-lang
[00:23:25] shmibs: has joined #elixir-lang
[00:32:28] ariedler: has joined #elixir-lang
[00:33:37] Cthalupa: has joined #elixir-lang
[00:34:04] neena: has joined #elixir-lang
[00:52:18] greengriminal: has joined #elixir-lang
[00:53:40] nikhilmore54: has joined #elixir-lang
[00:57:19] greengriminal: has joined #elixir-lang
[01:06:38] carldd: has joined #elixir-lang
[01:10:08] tomterl: has joined #elixir-lang
[01:19:52] ralmlopez: has joined #elixir-lang
[01:22:25] ralmlopez: has left #elixir-lang: ()
[01:26:31] mdbm_: has joined #elixir-lang
[02:07:12] tomterl: has joined #elixir-lang
[02:21:28] work_: has joined #elixir-lang
[02:24:09] duaneb: has joined #elixir-lang
[02:33:33] ariedler: has joined #elixir-lang
[02:43:24] kapil____: has joined #elixir-lang
[02:45:23] neena: has joined #elixir-lang
[03:01:56] Saukk: has joined #elixir-lang
[03:17:36] jeffro_: has joined #elixir-lang
[03:20:42] carldd: has joined #elixir-lang
[03:27:57] Cthalupa: has joined #elixir-lang
[04:07:01] DTZUZO: has joined #elixir-lang
[04:21:28] Cthalupa: has joined #elixir-lang
[04:25:56] lao-tzu: has joined #elixir-lang
[04:30:29] neena: has joined #elixir-lang
[04:34:22] ariedler: has joined #elixir-lang
[04:36:31] craigp: has joined #elixir-lang
[04:44:15] greengriminal: has joined #elixir-lang
[05:02:09] Avinash: has joined #elixir-lang
[05:08:10] nikhilmore54: has joined #elixir-lang
[05:18:29] jeffro_: has joined #elixir-lang
[05:20:35] neena: has joined #elixir-lang
[05:24:11] nikhilmore54: has joined #elixir-lang
[05:27:13] jeffro_: has joined #elixir-lang
[05:36:22] mdbm_: has joined #elixir-lang
[05:55:50] __charly__: has joined #elixir-lang
[06:13:49] neena: has joined #elixir-lang
[06:18:25] aert: has joined #elixir-lang
[06:20:31] DarkSeid: has joined #elixir-lang
[06:28:04] Avinash: has joined #elixir-lang
[06:30:58] iamvery: has joined #elixir-lang
[06:35:12] ariedler: has joined #elixir-lang
[06:37:33] serafeim: has joined #elixir-lang
[06:37:45] carldd: has joined #elixir-lang
[06:39:32] voltone: has joined #elixir-lang
[06:44:20] mim7: has joined #elixir-lang
[06:47:53] mim7: has joined #elixir-lang
[07:05:34] squall: has joined #elixir-lang
[07:18:02] lexmag: has joined #elixir-lang
[07:28:03] jeffro_: has joined #elixir-lang
[08:06:47] Sgeo_: has joined #elixir-lang
[08:07:48] msantos: has joined #elixir-lang
[08:19:02] aert: has joined #elixir-lang
[08:19:55] kapil____: has joined #elixir-lang
[08:24:11] iamvery: has joined #elixir-lang
[08:28:53] wonko7: has joined #elixir-lang
[08:29:37] iamvery: has joined #elixir-lang
[08:35:56] ariedler: has joined #elixir-lang
[08:39:37] iamvery: has joined #elixir-lang
[08:41:22] DTZUZO: has joined #elixir-lang
[09:04:12] nikhilmore54: has joined #elixir-lang
[09:20:35] dimitarvp: has joined #elixir-lang
[09:28:53] jeffro_: has joined #elixir-lang
[09:34:24] jeffro_: has joined #elixir-lang
[09:42:14] serafeim: has joined #elixir-lang
[09:42:53] serafeim: hello, I am trying to understand a simple controller. it has this line: render conn, "world.html", name: name
[09:43:04] serafeim: what's "render" ? is this a function? where are the parens ?
[09:44:23] serafeim: also what is the *last* parameter (i.e name: name) ? is this a Map ? if yes why it isn't defined like %{name: name} ? also how can I add more parameters i.e %{name: name, last_name: last_name} ?
[09:45:15] kyrylo: has joined #elixir-lang
[09:53:21] voltone: has joined #elixir-lang
[09:55:02] josevalim: Serafeim: hi!
[09:55:14] josevalim: Serafeim: I would recommend you to give a quick read on the Elixir getting stared guide
[09:55:31] josevalim: it is not really long and it will help you cement those concepts :)
[09:55:46] josevalim: https://elixir-lang.org/getting-started/introduction.html
[09:56:24] serafeim: i've read most of it however i keep forgetting stuff when i encounter it
[09:58:56] serafeim: ok i now see that parentheses are optional; so render is a function ?
[09:59:43] serafeim: what about the last parameter (name: name) ?
[10:00:11] Gazler: https://elixir-lang.org/getting-started/keywords-and-maps.html
[10:00:44] Gazler: > In general, when the keyword list is the last argument of a function, the square brackets are optional.
[10:01:02] DanielI: Phoenix.View.render/3 docs https://hexdocs.pm/phoenix/Phoenix.View.html#render/3
[10:01:12] serafeim: gazler and I can pass multiple keywords separated with commas ?
[10:02:05] serafeim: i.e will this work: render conn, "world.html", name: name, foo:bar
[10:02:22] serafeim: ok i thought that it may got confused and thought that render had 4 parameters
[10:02:25] Gazler: danieli: It is the controller render function. https://hexdocs.pm/phoenix/Phoenix.Controller.html#render/3
[10:02:48] serafeim: yes that's the one
[10:03:00] DanielI: oops, yeah, my bad! I copied the wrong link
[10:03:09] Gazler: render conn, "world.html", name: name, foo:bar is the same as render(conn, "world.html", [name: name, foo: bar])
[10:03:29] Gazler: Elixir ships with a formatter which will add parens in the correct (opinionated) places.
[10:03:39] jeffro_: has joined #elixir-lang
[10:03:49] serafeim: gazler great thanks
[10:04:18] serafeim: i think its much more clear this way :|
[10:06:29] Gazler: I use parens in most places, there are some macros where it doesn't make sense. defmodule Foo do ... end is nicer than `defmodule(Foo, do: ...)`
[10:10:55] serafeim: gazler yes I understand. also I tried mix format and it actually added the parentheses (but removed the [] from the keyword list)
[10:11:07] hypercore: has joined #elixir-lang
[10:19:41] ur5us: has joined #elixir-lang
[10:23:14] jeffro_: has joined #elixir-lang
[10:26:43] za1b1tsu: has joined #elixir-lang
[10:27:06] pereira_alex: has joined #elixir-lang
[10:28:41] za1b1tsu: anyway to update a dynamic list of keys in a map, but only if the keys exist?
[10:29:54] josevalim: za1b1tsu: `Enum.reduce(keys, map, fn key, acc -> if Map.has_key?(acc, key), do: ..., else: ... end)`
[10:32:21] za1b1tsu: josevalim, alright, I know the values, all are true, anyway I can use a Keyword list or something, to make it more readable?
[10:32:30] za1b1tsu: I can't use %{map | ....} because the keys are dynamic
[10:32:57] josevalim: %{map | key => value}
[10:33:02] josevalim: but that will raise if the keys do not exist
[10:33:25] josevalim: if you want to merge all keys (and add keys that do not exist), you can do `keyword |> Enum.into(map)`
[10:33:50] josevalim: otherwise you need to check the keys are explicitly there
[10:33:59] iamvery: has joined #elixir-lang
[10:35:56] za1b1tsu: l = ["code", "id"]; kl = Enum.into(l, [], &{String.to_atom(&1), true}); m = %{id: nil, code: nil, other: nil}; m = %{m | kl}
[10:36:34] za1b1tsu: (CompileError) iex:16: expected key-value pairs in a map, got: kl
[10:41:34] josevalim: za1b1tsu: oh, you are correct, you can't do all of them like that
[10:41:36] josevalim: you would have to do one by one
[10:42:19] josevalim: i still think Enum.reduce is the simplest in your case :)
[10:42:32] josevalim: Enum.reduce(keys, map, fn key, acc -> if Map.has_key?(acc, key), do: Map.put(acc, key, true), else: acc end)
[10:43:08] za1b1tsu: josevalim, indeed, thank you for this and everything else that you do
[10:55:09] ariedler: has joined #elixir-lang
[11:00:50] iamvery: has joined #elixir-lang
[11:42:42] netrino: has joined #elixir-lang
[11:52:24] netrino_: has joined #elixir-lang
[11:54:26] __charly__: has joined #elixir-lang
[12:04:11] pereira_alex: has joined #elixir-lang
[12:06:33] nikhilmore54: has joined #elixir-lang
[12:24:02] jeffro_: has joined #elixir-lang
[12:29:57] jeffro_: has joined #elixir-lang
[12:34:56] pereira_alex: has joined #elixir-lang
[12:40:24] Phylock: has joined #elixir-lang
[12:49:13] kapil____: has joined #elixir-lang
[13:04:54] uranoss: has joined #elixir-lang
[13:04:56] m3lt: has joined #elixir-lang
[13:17:21] pereira_alex: has joined #elixir-lang
[13:33:30] lauromoura_: has joined #elixir-lang
[13:47:31] pereira_alex: has joined #elixir-lang
[13:53:52] jeffro_: has joined #elixir-lang
[13:56:54] lexmag: has joined #elixir-lang
[13:57:59] wsieroci: has joined #elixir-lang
[13:59:23] duaneb: has joined #elixir-lang
[14:00:30] jeffro_: has joined #elixir-lang
[14:07:12] gvaughn: has joined #elixir-lang
[14:14:06] lauromoura_: has joined #elixir-lang
[14:25:04] gvaughn: has joined #elixir-lang
[14:25:11] lexmag: has joined #elixir-lang
[14:32:43] lexmag: has joined #elixir-lang
[14:38:38] za1b1tsu: has joined #elixir-lang
[14:47:19] lexmag: has joined #elixir-lang
[14:54:37] ryotsu: has joined #elixir-lang
[15:07:16] definiv: has joined #elixir-lang
[15:08:41] tnez: has joined #elixir-lang
[15:09:44] PragTob: has joined #elixir-lang
[15:21:38] aalmazan: has joined #elixir-lang
[15:40:56] dimitarvp: has joined #elixir-lang
[15:44:59] tallysmartins_: has joined #elixir-lang
[15:47:15] greengriminal: has joined #elixir-lang
[15:54:42] wsieroci: has joined #elixir-lang
[15:56:46] proteusguy: has joined #elixir-lang
[15:57:13] wsieroci_: has joined #elixir-lang
[15:58:24] nikhilmore54: has joined #elixir-lang
[15:59:52] gvaughn_: has joined #elixir-lang
[16:10:57] pera: has joined #elixir-lang
[16:25:14] wonko7: has joined #elixir-lang
[16:29:15] tpl: has joined #elixir-lang
[16:30:37] za1b1tsu: has joined #elixir-lang
[16:38:21] Guest: has joined #elixir-lang
[16:42:20] ariedler: has joined #elixir-lang
[17:02:44] jeffro: has joined #elixir-lang
[17:06:35] nikhilmore54: has joined #elixir-lang
[17:07:53] jmiven: has joined #elixir-lang
[17:09:44] rambocoder: has joined #elixir-lang
[17:23:24] laut: has joined #elixir-lang
[17:41:09] lauromoura_: has joined #elixir-lang
[17:44:55] PragTob: has joined #elixir-lang
[17:52:55] PragTob: has joined #elixir-lang
[18:08:38] DanielI: has left #elixir-lang: ("Alpine Linux, the security-oriented, lightweight Linux distribution")
[18:18:30] jeffro: has joined #elixir-lang
[18:26:44] gabrielpoca: has joined #elixir-lang
[18:29:25] Cthalupa: has joined #elixir-lang
[18:54:23] iamvery_: has joined #elixir-lang
[19:01:38] mayhew: has joined #elixir-lang
[19:21:40] work_: has joined #elixir-lang
[19:28:38] kyrylo: has joined #elixir-lang
[19:34:36] ailo_: has joined #elixir-lang
[20:57:04] jfis: has joined #elixir-lang
[20:59:43] DarkSeid: has left #elixir-lang: ("Textual IRC Client: www.textualapp.com")
[21:04:19] Phylock: has joined #elixir-lang
[21:04:31] mat_bug_: has joined #elixir-lang
[21:13:32] nageV: ailo_: see https://elixirschool.com/en/lessons/libraries/benchee/
[21:14:58] griffinbyatt: has joined #elixir-lang
[21:18:03] notzmv: has joined #elixir-lang
[21:24:52] mat_bug: has joined #elixir-lang
[21:44:17] mat_bug_: has joined #elixir-lang
[21:48:56] tallysmartins_: has joined #elixir-lang
[21:58:15] mat_bug: has joined #elixir-lang
[22:12:14] gvaughn: has joined #elixir-lang
[22:13:39] mat_bug: has joined #elixir-lang
[22:19:12] __charly__: has joined #elixir-lang
[22:23:42] mim7: has joined #elixir-lang
[22:23:42] mim7: has joined #elixir-lang
[22:28:06] mat_bug: has joined #elixir-lang
[22:35:01] craigp: has joined #elixir-lang
[22:43:00] greengriminal: has joined #elixir-lang
[23:00:35] gvaughn_: has joined #elixir-lang
[23:10:02] mat_bug: has joined #elixir-lang
[23:11:04] infowolfe: has joined #elixir-lang
[23:11:04] infowolfe: has joined #elixir-lang
[23:12:34] duaneb: has joined #elixir-lang
[23:33:18] iFire: has joined #elixir-lang