Library reference

Find an item in a list

Check whether a particular value appears anywhere in a list. A single match is enough.

in

Simple example

Does the list contain two?

Start1 · 2 · 3
Resulttrue
lesson.jl
function main()
    values = [1, 2, 3]
    println(2 in values)
end

main()
Output
true
Advertisements

Everyday examples

Is ticket 17 on the pickup list?

Start15 · 17 · 20
Resulttrue
lesson.jl
function main()
    values = [15, 17, 20]
    println(17 in values)
end

main()
Output
true

Does this bus stop at stop 6?

Start2 · 4 · 8
Resultfalse
lesson.jl
function main()
    values = [2, 4, 8]
    println(6 in values)
end

main()
Output
false

Is parcel 42 on the van?

Start42 · 18 · 15
Resulttrue
lesson.jl
function main()
    values = [42, 18, 15]
    println(42 in values)
end

main()
Output
true
Run the example
Terminal
julia lesson.jl
Official documentation