# Range vs. Array

**URL:** <https://discourse.julialang.org/t/range-vs-array/25171>\
**Category:** General Usage\
**Tags:** question, array\
**Created:** [June 12, 2019, 12:07am UTC](https://discourse.julialang.org/t/range-vs-array/25171 "2019-06-12T00:07:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mroavi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mroavi/32/8804_2.png) [@mroavi](https://discourse.julialang.org/u/mroavi)\
**Post date:** [June 12, 2019, 12:07am UTC](https://discourse.julialang.org/t/range-vs-array/25171/1 "2019-06-12T00:07:20Z")

</div>

I would like to understand why the two statements below generate different results. I was expecting both results to be the same (equal to the one produced by the second statement). I’m running Julia Version 1.1.0 (2019-01-21).

```julia
julia> sqrt.(10.0 * 1:100)
91-element Array{Float64,1}:
  3.1622776601683795
  3.3166247903554
  3.4641016151377544
  3.605551275463989
  3.7416573867739413
  3.872983346207417
  ⋮
  9.746794344808963
  9.797958971132712
  9.848857801796104
  9.899494936611665
  9.9498743710662
 10.0

julia> sqrt.(10.0 * collect(1:100))
100-element Array{Float64,1}:
  3.1622776601683795
  4.47213595499958
  5.477225575051661
  6.324555320336759
  7.0710678118654755
  7.745966692414834
  ⋮
 30.822070014844883
 30.983866769659336
 31.144823004794873
 31.304951684997057
 31.464265445104548
 31.622776601683793

```

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [June 12, 2019, 12:17am UTC](https://discourse.julialang.org/t/range-vs-array/25171/2 "2019-06-12T00:17:54Z")

</div>

`*` has a higher precedence than `:`, so your first example is equivalent to `sqrt.((10.0 * 1):100)`. You’re probably looking for `sqrt.(10.0 .* (1:100))`.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [June 12, 2019, 12:19am UTC](https://discourse.julialang.org/t/range-vs-array/25171/3 "2019-06-12T00:19:10Z")

</div>

Ah, beat me by like 10 seconds 😉
