Search a list of records: Difference between revisions

m
Formatting.
m (Formatting.)
Line 1,888:
echo "Index of the first city whose name is “Dar Es Salaam”: ",
Cities.findIt(it.name == "Dar Es Salaam")
 
let idx1 = Cities.findIt(it.population < 5)
echo "Name of the first city whose population is less than 5 million: ",
if idx1 == -1: "<none>" else: Cities[idx1].name
 
let idx2 = Cities.findIt(it.name.startsWith("A"))
echo "Population of the first city whose name starts with the letter “A”: ",
Anonymous user