Hal9000
Variables leaking
I’ve been thinking about the change made 2-3 years ago where it’s
no longer permitted to set variables inside a case statement (or similar).
Is it fair to summarize this by saying: Variable values can pass from an
outer context to a more inner one, but those variables cannot be bound
to new values (such that the outer context changes)?
This afaik applies to any “block” of code nested inside a larger context –
the “guts” of an if, case, cond, code passed to a macro…
Am I looking at this correctly or not?
Hal
First Post!
hauleth
In short ways, binding is valid only within it’s block.
x = 1
if true do
# we start new block there
x = 2
# there `x` has new binding
end # block ended so all it's bindings as well
# there `x` has meaning of it's previous binding
0
Last Post!
Hal9000
Yes, thank you…
Of course, the value of x is still known inside the block until it is reassigned…
x = 1
IO.puts x
if true do
IO.puts x
x = 2
IO.puts x
end
IO.puts x
# Prints: 1, 1, 2, 1
Hal
0
Popular in Discussions
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
If so I (and hopefully others!) might have some tips for you :slight_smile:
But first, please say which area you’re finding most challen...
New
Hello everyone,
I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Hi all,
In the last days, two things happened:
A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
What learn first? Rust or Elixir
Hi Elixir community!
I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
Other popular topics
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
Hello everyone,
Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









