sabo66

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

LostKobrakai

Sounds like a usecase for Enum.chunk_while or the Stream.chunk_while counterpart.

al2o3cr

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_while to bring together each line starting with a letter and all the following lines that start with a number
  • Stream.flat_map over each of those chunks:
    • one row of output with number: nil for the line that starts with the letter
    • one row of output for each line that starts with a number using the letter from above
zachdaniel

zachdaniel

Creator of Ash

To answer your specific question: no, you cannot assign a value to a variable in a higher scope :slight_smile:

So even if it was a good idea, you couldn’t do it.

Where Next?

Popular in Discussions Top

blackode
Elixir Upgrading is so Simple in Ubuntu and It worked for me Ubuntu 16.04 git clone https://github.com/elixir-lang/elixir.git cd elixir...
New
Rustixir
Hi everyone, im working on find best language/framework/system for high concurrency, high performance and stable performance after wor...
New
MarioFlach
Hello, I want to share a project I’ve been working on for a while: https://github.com/almightycouch/gitgud Background Some time ago I ...
New
fireproofsocks
This is more of a general question, but I’m wondering how other people in the community think about the pattern matching in function sign...
New
pillaiindu
I want to convert a Phoenix LiveView CRUD website to a CRUD mobile app. What do you think is the easiest way to do so?
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New
AstonJ
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
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New

Other popular topics Top

Darmani72
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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement