Ad space (banner)
๐ŸŸฃJulia Lessons
Lesson 7 / 68

Working with arrays

This lesson covers the basics of using arrays in Julia, with the aim of handling several pieces of data together.

An array is like a shelf of numbered drawers. [ ] creates one, and enumerate() takes the elements out with their numbers.

The sample code builds an array with fruits = ["apple", "orange", "grape"] and displays each element with a number, taking index and value together with enumerate(fruits). Note that Julia arrays are indexed from 1.

A common early stumble is exactly that: indexes start at 1, not 0. Most other languages (Python, JavaScript) start at 0, so the difference trips people up on arriving at Julia.

In professional work, the array is Julia's most basic data structure, used throughout numerical and data-analysis code.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Julia directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)