|
|
Subscribe / Log in / New account

An introduction to the Julia language, part 1

An introduction to the Julia language, part 1

Posted Aug 30, 2018 10:35 UTC (Thu) by cagrazia (guest, #124754)
Parent article: An introduction to the Julia language, part 1

     while i < 5
            print(i)
            global i = i + 1
      end
but... i is undefined in the first line... how can the loop start?


to post comments

An introduction to the Julia language, part 1

Posted Aug 30, 2018 12:07 UTC (Thu) by leephillips (subscriber, #100450) [Link] (1 responses)

On the line before the block:

julia> i = 1;

.... in the global scope of the REPL.

An introduction to the Julia language, part 1

Posted Sep 2, 2018 21:20 UTC (Sun) by billygout (guest, #70918) [Link]

What's more confusing to me is that `global` was needed in the assignment statement in the loop, but not in the first line in the loop `print(i)`. Why would that be?


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds