As I am just starting my adventure with programming in general and with Swift in particular I am unable to solve my problem with filtering an array.
While working with my book, I got to a chapter where arrays are explained and I had no problem with working with arrays untill now. Here is a code from my student's book :
var city = ["Boston", "London", "Chicago", "Atlanta"]
let filtered = city.filter{$0.range(of:"o") != nil}
This is supposed to filter the cities with the letter "o" in it but when compiled this message is being shown :
error: value of type 'String' has no member 'range
So does it mean that I can't use .range for string values?
What chould the code look like then?
I am using ubuntu as my OS.
Thanks in advance.
import Foundation?containsto check whether astringhas acharacterlet filtered = city.filter{$0.contains("o")}let filtered = city.filter{$0.characters.contains("o")}