forio / julia-studio

An IDE for the Julia Language
forio.com/products/julia-studio
GNU General Public License v3.0
223 stars 48 forks source link

Problem with if else in Julia #259

Closed Lytu closed 9 years ago

Lytu commented 9 years ago

When i do: M=rand(5,5) a=M[:,1]' * M[:,1] if a<0 println("Less than 0") else println("more") end

I have an error: " isless has no method matching isless(::Array{Float64,2}, ::Int 32) in < at operators.jl:32

Can anyone tell me please how to do this? Thank you

WestleyArgentum commented 9 years ago

I'm not sure exactly what you're trying to do, but you're problem is with a=M[:,1]' * M[:,1]. I recommend you print that value out -- it ends up being a multidimensional array, not a number. Docs here: http://docs.julialang.org/en/release-0.3/manual/arrays/

And again, in the future, it's best to ask things on the users group (https://groups.google.com/forum/#!forum/julia-users) because very few people will see them here.