erlang - How to access a variable from a method which was set in another method of the same module in elixir? -


i want access argument x of m1 method m2 method.

defmodule mymodule      def m1(x)         # code     end      def m2()         # accesss 'x' here         io.puts x     end end 

how access x method m2?

you can't this. forbidden operation in beam in erlang , elixir , other beam based languages. intended behavior have provide transparently required input data each function call. can emulate using other components of erlang run-time system (erts). example, use ets (erlang term storage) or use process working server providing such storage. constraint fundamental building block making highly reliable systems primal purpose of erlang. more information read making reliable distributed systems in presence of software errors thesis. described best there @ beginning of work.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -