# Help with updating a legacy Julia code

**URL:** <https://discourse.julialang.org/t/help-with-updating-a-legacy-julia-code/33013>\
**Category:** New to Julia\
**Created:** [January 6, 2020, 1:35am UTC](https://discourse.julialang.org/t/help-with-updating-a-legacy-julia-code/33013 "2020-01-06T01:35:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gfaccin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gfaccin/32/12140_2.png) [@gfaccin](https://discourse.julialang.org/u/gfaccin)\
**Post date:** [January 6, 2020, 1:35am UTC](https://discourse.julialang.org/t/help-with-updating-a-legacy-julia-code/33013/1 "2020-01-06T01:35:53Z")

</div>

Hi all,

I’m completely new to Julia.

I’ve got a Julia simulation code that seems to have been written in an old version of Julia. Thus, it uses a lot of deprecated syntax which fails to execute in the version I have (which is 1.3.0).

I’ve managed to carefully search for the compilation errors and update the code to reflect the current Julia syntax. However, there’s this piece of code that, being a total noob to Julia, I’m unable to understand.

This is the offending line of code:

_rnew = drmax._(rand(nDim)-0.5);\*

which results in the following error:

_ERROR: LoadError: MethodError: no method matching -(::Array{Float64,1}, ::Float64)_  
_Closest candidates are:_

- -(!Matched::Float64, ::Float64) at float.jl:403\*
- -(!Matched::Complex{Bool}, ::Real) at complex.jl:303\*
- -(!Matched::Missing, ::Number) at missing.jl:115\*

Could anyone point me to how I can fix this so that it runs?

Thank you!

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [January 6, 2020, 1:48am UTC](https://discourse.julialang.org/t/help-with-updating-a-legacy-julia-code/33013/2 "2020-01-06T01:48:16Z")

</div>

> [@gfaccin](#):
>
> rand(nDim)-0.5

You probably want:

```julia
rand(nDim) .- 0.5

```

See [Functions · The Julia Language](https://docs.julialang.org/en/v1/manual/functions/#man-vectorized-1)

Also note that Julia version 0.7 is useful for upgrading older versions, because it contains deprecation warnings to help you.

In your case, running the code in Julia 0.7 produces the following:

```julia
julia> rand(nDim)-0.5
┌ Warning: `a::AbstractArray - b::Number` is deprecated, use `a .- b` instead.
│ caller = top-level scope at none:0
└ @ Core none:0

```

---

<div class="post-metadata">

**Author:** ![gfaccin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gfaccin/32/12140_2.png) [@gfaccin](https://discourse.julialang.org/u/gfaccin)\
**Post date:** [January 6, 2020, 2:26am UTC](https://discourse.julialang.org/t/help-with-updating-a-legacy-julia-code/33013/3 "2020-01-06T02:26:56Z")

</div>

Thank you! Looks like it dit it.
