sabo66
Assign global variable from a local scope?
Hello I’m new in Elixir, it is possible to assign a global variable from a local scope ?
ex
case x do
"text" -> global_var = 1
end
Most Liked
LostKobrakai
Sounds like a usecase for Enum.chunk_while or the Stream.chunk_while counterpart.
al2o3cr
That’s… not a thing.
The strict definition of a CSV would be a file that conforms to RFC4180 - comma delimited, fields with commas escaped with " etc
The “loose” definition expands that to using single characters other than , (tabs, pipes, etc) as a delimiter.
But saying “the delimiter is =>” stretches that definition beyond reason.
Regarding your original question, +1 for starting with Stream.chunk_while. A possible sequence of operations could look like this:
- use
Stream.chunk_whileto bring together each line starting with a letter and all the following lines that start with a number Stream.flat_mapover each of those chunks:- one row of output with
number: nilfor the line that starts with the letter - one row of output for each line that starts with a number using the letter from above
- one row of output with
zachdaniel
To answer your specific question: no, you cannot assign a value to a variable in a higher scope ![]()
So even if it was a good idea, you couldn’t do it.
Popular in Discussions
Other popular topics
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
- #javascript
- #code-sync
- #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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









