Giter Club home page Giter Club logo

Comments (5)

paulo-ferraz-oliveira avatar paulo-ferraz-oliveira commented on May 30, 2024

I don't see how #{key := A, x := X, y := Y, key := B} = ZZZ can "be very confusing". It's pattern-matching at its best.

If I understand your message well, there's some confusion here.

The first clause is pattern-matching. The second clause is single variable assignment.

from elvis_core.

elbrujohalcon avatar elbrujohalcon commented on May 30, 2024

@paulo-ferraz-oliveira it's related to this. Notice the repetition of key in the first pattern.

from elvis_core.

paulo-ferraz-oliveira avatar paulo-ferraz-oliveira commented on May 30, 2024

@paulo-ferraz-oliveira it's related to this. Notice the repetition of key in the first pattern.

Oh, I got it. Them details...

In any case, what's so wrong about assigning to two different variables? You'll eventually either use both or only one (if using only one the compiler will already warn you). Is the confusion part the fact that they hold the same value for different names?

from elvis_core.

elbrujohalcon avatar elbrujohalcon commented on May 30, 2024

Assigning the same value to 2 variables can be done like this…

#{key := A = B, x := X, y := Y} = ZZZ,

…which is, at least, more explicit.

from elvis_core.

elbrujohalcon avatar elbrujohalcon commented on May 30, 2024

This is already taken care of by the Erlang compiler. It emits warnings such as…

your_module.erl:9:60: Warning: key 'a' will be overridden in expression
%    9|     Other = NewMap#{even := using, different => accessors, a => "arrow", a := "not arrow"},
%     |                                                            ^

from elvis_core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.