# My Brain Is Hard-Wired Against ==; Help Me, Julia

**URL:** https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532
**Category:** New to Julia
**Tags:** question, syntax
**Created:** [June 25, 2021, 6:16am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532 "2021-06-25T06:16:33Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![cvanaret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cvanaret/32/11594_2.png) [@cvanaret](https://discourse.julialang.org/u/cvanaret)
#### Post date: [June 25, 2021, 12:16pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/21 "2021-06-25T12:16:55Z")

</div>

> [@blackeneth](#):
>
> ```julia
> if member=="SB" ...etc
> if member=="SL" ...etc
> if member=="SU" ...etc
> if member="SN" ... etc
> if member="ST" ... etc
> if member="AUTO" ... etc
> 
> ```
> 
> Yes, in writing six lines of code, I made the mistake _3 times._ Then I cut and pasted it into about 4 other places.

My 2 cents: add spaces before and after the “==”. It’ll make errors more obvious:

```julia
if member == "SB" ...etc
if member == "SL" ...etc
if member == "SU" ...etc
if member = "SN" ... etc
if member = "ST" ... etc
if member = "AUTO" ... etc

```

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [June 25, 2021, 12:32pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/22 "2021-06-25T12:32:19Z")

</div>

Turns out there is already a lint for this in the VS code plugin:

![image](https://global.discourse-cdn.com/julialang/original/3X/b/4/b4f3b2d280af2687aa6c00207a9872e0d4bd5dee.png)

and hovering over the blue underline shows this message:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/c/5c182112d0c091914f8998cf9d7cb095113de14c.png)

---

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [June 25, 2021, 2:11pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/24 "2021-06-25T14:11:42Z")

</div>

it’s like a new category, asking for syntax change 2nd I’ve seen this on this forum. interesting. doubt it will happen. also just something to get used to

---

<div class="post-metadata">

### Author: ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)
#### Post date: [June 25, 2021, 2:44pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/25 "2021-06-25T14:44:52Z")

</div>

You have other options in Julia than inventing a new unicode. `isequal` is equivalent to `==` in most cases (NaN, missing, -0.0 are exceptions). Choose the one best in your eyes, to me the last is awesome.

```julia
julia> x = 5;

julia> if x == 5
           println("x is five!")
       end
x is five!

julia> isequal(x, 5) && println("x is five!")
x is five!

julia> x == 5 && println("x is five!")
x is five!

```

---

<div class="post-metadata">

### Author: ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)
#### Post date: [June 25, 2021, 2:51pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/26 "2021-06-25T14:51:45Z")

</div>

@Seif_Shebl my thoughts exactly. Use the function!

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [June 25, 2021, 2:57pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/28 "2021-06-25T14:57:30Z")

</div>

This is definitely not going to happen, but I think the ideal syntax is for `=` to represent boolean equality and for the assignment operator to be either `:=`, `<-`, or `←`.

Luckily downvoting is not possible on Discourse. I know that there is a lot of hate for the `<-` assignment operator in R. 😂

---

<div class="post-metadata">

### Author: ![mjyshin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mjyshin/32/26449_2.png) [@mjyshin](https://discourse.julialang.org/u/mjyshin)
#### Post date: [June 25, 2021, 5:03pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/29 "2021-06-25T17:03:03Z")

</div>

The mathematician in me agrees with `:=` for assignment and `=` for boolean, but since (as you say) it will probably never happen (just as the physical flow of electrons will always be negative current in that direction), maybe you can trick your brain into reading `==` as “is (=) equal to (=)”. Like `!=` is read “not (!) equal to (=)”, and `>=` is read “greater than or (\>) equal to (=)”. Sometimes you just gotta take the placebo pill and hope it works.

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [June 25, 2021, 5:03pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/30 "2021-06-25T17:03:29Z")

</div>

I realize I’m not being too helpful, but if you insist on = for equality, you can with:

> **[GitHub - swadey/LispSyntax.jl: lisp-like syntax in julia](https://github.com/swadey/LispSyntax.jl)**
>
> lisp-like syntax in julia. Contribute to swadey/LispSyntax.jl development by creating an account on GitHub.

> The net result is that LispSyntax.jl is really an alternative S-expression-like syntax for julia, not an implemention of clojure or lisp.

You’ll get more than you bargained for, a whole new language/syntax (while keeping Julia semantics), and that applies double for APL.jl:

[https://news.ycombinator.com/item?id=27462090](https://news.ycombinator.com/item?id=27462090)

For languages with = for equality (I’m really conflicted on that better), then you need an alternative for assignment, and this seems like a valid option, while you need twice the number of keystrokes for the more common operator:

> [@CameronBieganek](#):
>
> a lot of hate for the `<-` assignment operator in R

The downside for Lisp/Scheme/Clojure as above is assignment is even longer (not sure how it’s done in APL), e.g. set! for:

```julia
shell> julia --lisp
; _
; |_ _ _ |_ _ | . _ _
; | (-||||_(_)|__|_)|_)
;-------------------|----------------------------------------------------------

```

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [June 25, 2021, 7:47pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/31 "2021-06-25T19:47:02Z")

</div>

In MathCad 14 I type  
: to get the assignment :=  
Ctrl = to get the Boolean equal shown as a bold =  
= to find the contents of a variable  
{ for a local assignment operator ← (used in their programming blocks)

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [June 25, 2021, 7:57pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/32 "2021-06-25T19:57:00Z")

</div>

Which VS code plugin is that?

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [June 25, 2021, 9:17pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/33 "2021-06-25T21:17:05Z")

</div>

It’s the Julia extension (1.2.5) . It works for me too and shows the problem:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/c/9cfed4441867b0ec180b0ea5b8d2ea938d5a04c0.png)

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [June 25, 2021, 10:48pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/34 "2021-06-25T22:48:21Z")

</div>

I don’t get any linting at all on Mac.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [June 25, 2021, 11:11pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/35 "2021-06-25T23:11:38Z")

</div>

Check your julia-vscode verson?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [June 25, 2021, 11:30pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/36 "2021-06-25T23:30:04Z")

</div>

It auto updates to the latest version. Which version do i need? There’s no setting that needs to be activated?

---

<div class="post-metadata">

### Author: ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)
#### Post date: [June 25, 2021, 11:58pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/37 "2021-06-25T23:58:38Z")

</div>

Assignment is the most frequently used operator, it should be ONE character operator. In contrast to most people in this thread, I found `=` and `==` is intuitive to be used as the assignment and comparison operators, respectively.

---

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [June 26, 2021, 12:29am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/38 "2021-06-26T00:29:21Z")

</div>

The nice thing about brains is that they are _very_ good at rewiring themselves. Try writing some code that helps you practice the distinction between `=` and `==`. At first you’ll stumble a lot as you’ve already done, and it’ll feel frustrating, but after getting a good night sleep, your troubles should be behind you and you won’t have to think about this anymore.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [June 26, 2021, 1:16am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/39 "2021-06-26T01:16:34Z")

</div>

It is funny: I _never_ get this wrong in `if` branches or broadcasted comparisons (`.==`) or general logic flow but I _frequently_ do it wrong with `@test x = 2`. Something about the context or something. Guess I need more practice writing tests…

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [June 26, 2021, 2:52am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/40 "2021-06-26T02:52:02Z")

</div>

I believe that the decision of having a `=` and `==` was an error of the past, but trying to go against it now would be another error, at least for Julia (that values the similarity with Matlab and other languages).

Julia greatly minimizes the problem by only allowing `Bool` in the `if` clause. In your typical C/C++ code, lots of equality comparisons are between integers and most integers are allowed in an `if` clause, so a `x = 5` is not an error but a much worse silently bug. The [Yoda Conditions](https://en.wikipedia.org/wiki/Yoda_conditions) were proposed to minimize the effects of the problem (yet, they only help if one side of the comparison is a literal or constant).

You clearly are not alone, [I have answered someone with a similar problem in the past](https://discourse.julialang.org/t/julia-equivalent-of-rm-almost/39477/2). In their case, the problem was that even if the code results in an error, you lose the value of the overwritten variable, what is a bother when you are working with Jupyter and the like.

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [June 26, 2021, 3:27am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/41 "2021-06-26T03:27:29Z")

</div>

> [@liuyxpp](#):
>
> Assignment is the most frequently used operator, it should be ONE character operator.

I don’t know, I think `\leftarrow[TAB]` is pretty easy to type. 😉

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [June 26, 2021, 3:36am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/42 "2021-06-26T03:36:57Z")

</div>

It seems like there’s some confusion about OP’s request. They’re just asking for an alias in Base. Many operators have aliases, they’re just asking for one for `==`.

[Previous page](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532.md?page=1)

[Next page](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532.md?page=3)
