# 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:** 3

<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 26, 2021, 3:40am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/43 "2021-06-26T03:40:57Z")

</div>

Not at all. Just `\` will drive me crazy. I always confused it with `/`. Furthermore, at least three keystrokes (autocomplete considered) are needed to type the left arrow. Maybe you have a better way?

---

<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 26, 2021, 3:43am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/44 "2021-06-26T03:43:08Z")

</div>

I am more interested to see a well designed operator for explicitly carrying out float number comparison.

---

<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:47am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/45 "2021-06-26T03:47:16Z")

</div>

If `≈` isn’t good enough then let’s talk about it (in a separate thread please).

---

<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:52am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/46 "2021-06-26T03:52:38Z")

</div>

I was kidding, hence the winking emoji.

---

<div class="post-metadata">

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

</div>

I know Julia is not going to change, and I do not expect it to.  
I learned Pascal early on (on punched cards) The assignment operator is :=  
I still think ‘becomes equal to’ when writing code

The comparison operator could be ?=  
I would read that as ‘query equals’

---

<div class="post-metadata">

### Author: ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)
#### Post date: [June 26, 2021, 11:42am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/48 "2021-06-26T11:42:15Z")

</div>

If it’s been 20 years, how much sleep do I need?

---

<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, 1:43pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/49 "2021-06-26T13:43:56Z")

</div>

Perhaps alternate back and forth between an hour of programming and an hour of deep, meditative trance. 🙂

---

<div class="post-metadata">

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

</div>

One style I have seen to reduce the problem is to flip the sides of the equality test. That often places something that cannot be assigned to and gives an error.

```julia
julia> a = 20
20

julia> 0 == a
false

julia> 0 = a
ERROR: syntax: invalid assignment location "0" around REPL[3]:1

```

---

<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, 6:37pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/51 "2021-06-26T18:37:31Z")

</div>

Shoot, usually “try turning it off and on again” is enough to fix these things, I’m out of ideas!

---

<div class="post-metadata">

### Author: ![miguelraz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miguelraz/32/631_2.png) [@miguelraz](https://discourse.julialang.org/u/miguelraz)
#### Post date: [June 26, 2021, 6:59pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/52 "2021-06-26T18:59:59Z")

</div>

To join the bikeshed, I think linter integration into IDEs will be the most value for effort mitigation for this. Maybe JET.jl can handle it - try it out!

---

<div class="post-metadata">

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

</div>

Every LanguageServer.jl compatible editor already emits a warning in this case, as demonstrated upthread.

---

<div class="post-metadata">

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

</div>

Ah, I think I just scrolled past that. Awesome!

---

<div class="post-metadata">

### Author: ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)
#### Post date: [June 28, 2021, 7:08pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/55 "2021-06-28T19:08:41Z")

</div>

My brain is hard-wired against `=` copying by reference.  
Why do we need to use `copy()` every time we want to copy the content of an object.  
I think most of the time users want to copy the content, not create references.  
`=` should be the default way to copy object content.

---

<div class="post-metadata">

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

</div>

> [@liuyxpp](#):
>
> In contrast to most people in this thread, I found `=` and `==` is intuitive to be used as the assignment and comparison operators, respectively.

The unfortunate thing is that negation has become inconsistent because of this choice. The negation of most operations are

```julia
!<op>

```

but the negation of `==` is `!=`. And this is blocking a feature I’d really like to see: [! for infix operators · Issue #25512 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/25512)

A possible way out would be to have `!==` and `!===`, but they would be really long. Also, it’s of course never going to happen.

Assignment as `:=` would be wonderful, and not too long at all.

---

<div class="post-metadata">

### Author: ![Rui](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@Rui](https://discourse.julialang.org/u/Rui)
#### Post date: [June 28, 2021, 9:26pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/57 "2021-06-28T21:26:45Z")

</div>

What about using espanso or just remap a key (that you don’t press with your pinky) to input == ?

---

<div class="post-metadata">

### Author: ![apo383](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/apo383/32/11272_2.png) [@apo383](https://discourse.julialang.org/u/apo383)
#### Post date: [June 28, 2021, 10:01pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/58 "2021-06-28T22:01:33Z")

</div>

> [@Juan](#):
>
> most the time users want to copy the content

I usually think similarly, but not in Julia where I’ve gotten used to another way of doing things. My experience with Matlab made me very happy with copy-on-write, but now Instead of

```julia
b = copy(a)
b[someelement] = newvalue

```

I’ve gradually learned to copy and mutate simultaneously, e.g. using `map`, generators, and broadcasting. Quick anonymous functions make this easy. I don’t even do much piping `|>` but that can even be more concise. It’s nice to borrow some approaches from functional programming without having to go all the way.

---

<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 29, 2021, 2:23am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/59 "2021-06-29T02:23:30Z")

</div>

Yes, those are called [Yoda Conditions](https://en.wikipedia.org/wiki/Yoda_conditions) and were mentioned before in this thread.

---

<div class="post-metadata">

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

</div>

Hi blackeneth,

People do seem to have strange names on the internet. Anyway, I was just wondering how old you are? I’m 68 and this really isn’t a big problem. There are many languages that do the same thing, it’s not special to Julia.

I can offer you a simple suggestion which may help. PostIt notes, just stick one to your monitor with:

= for assignment  
== for test

After a while, I’m sure you will break your habit. It’s like most things “practice makes perfect” or in this case “improves your memory”. But, one thing that won’t help is to get overstressed by it. Relax, have a drink and just go “oops did it again no big deal”.

Kindest regards

Jeremy

---

<div class="post-metadata">

### Author: ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)
#### Post date: [June 29, 2021, 6:01pm UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/61 "2021-06-29T18:01:30Z")

</div>

I dislike ← in R almost as much as I do := in Pascal…

---

<div class="post-metadata">

### Author: ![rjmoses](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rjmoses](https://discourse.julialang.org/u/rjmoses)
#### Post date: [June 30, 2021, 9:25am UTC](https://discourse.julialang.org/t/my-brain-is-hard-wired-against-help-me-julia/63532/62 "2021-06-30T09:25:03Z")

</div>

I agree: “==” is an abomination upon mankind. I once spent six months trying to find why an error recovery routine blew up in a C program. It was because a programmer had written “if (a = b) { … }” which always resolved as true.

I can’t tell you how many times I looked at that code and saw what I thought rather than what was actually being done.

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

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