Comments (5)
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.
@paulo-ferraz-oliveira it's related to this. Notice the repetition of key
in the first pattern.
from elvis_core.
@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.
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.
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)
- New rule: No Single Clause Maybe Statements
- New rule: Consistent Line Endings
- New rule: Consistent Trailing Blank Line HOT 3
- New rule: Redundant Blank Lines HOT 2
- New rule: Prefer Unquoted Atoms
- `rebar3 lint` unexpectedly warns `_Var ?= val` as `used_ignored_variable` HOT 1
- Drop support for OTP versions below 23. HOT 2
- Broken README links HOT 3
- There are instances where not exporting a type is valid, even if it's used in a spec.
- Add option to ignore non-exported functions on max_function_arity HOT 1
- Unused Variable Names HOT 5
- no_match_in_condition reports a warning even when the condition includes a valid match
- Bug (?) in atom_naming_convention HOT 2
- Using ets:fun2ms without including ms_transform.hrl should be an error HOT 3
- New ruleset `gitignore`
- Propose `gen_server` et all "no-timeout" functions as `no_common_caveats`?
- Have a simple way to run `all` checks (even optional ones) HOT 8
- New rule: consistent file names HOT 2
- New Rule: No Import Type
- New Rule: Unsafe usage of application HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elvis_core.