how does one do M:F() calls ?

53 vues
Accéder directement au premier message non lu

Alex Shneyderman

non lue,
15 avr. 2014, 15:23:2915/04/2014
à elixir-l...@googlegroups.com
In Erlang I can do -

M = erlang
F = now

M:F() 

I am trying to figure out how a thing like that can be done in Elixir. Any hints?

iex(1)> m = System

iex(2)> m.tmp_dir()

"/var/folders/pk/r9_ncwsn6qq91bpjbhyxgg400000gn/T/"

iex(3)> f = :"tmp_dir"

iex(4)> m.f()         

** (UndefinedFunctionError) undefined function: System.f/0

    (elixir) System.f()



Michael Simpson

non lue,
15 avr. 2014, 15:25:1215/04/2014
à elixir-lang-talk
To call out to Erlang it's :m.f in Elixir it's just m.f


--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

José Valim

non lue,
15 avr. 2014, 15:27:2415/04/2014
à elixir-l...@googlegroups.com
Michael, in his case, they are variables.

Alex, just use apply/3:

apply(System, :tmp_dir, [])



José Valim
Skype: jv.ptec
Founder and Lead Developer

Michael Simpson

non lue,
15 avr. 2014, 16:25:2615/04/2014
à elixir-lang-talk
Thanks José, I shouldn't have replied after just skimming the email. Next time I'll read a little closer.

José Valim

non lue,
15 avr. 2014, 17:21:5115/04/2014
à elixir-l...@googlegroups.com

Thanks José, I shouldn't have replied after just skimming the email.

We have all done that :D



--
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message