Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEric Witowski
Courses Plus Student 92 PointsRange Question
var sentence = "All boys do a really good job cleaning."
use the range() method to locate the word "do" in the sentence and assign the range to a variable.
2 Answers
Brandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsI did this from my phone so it's not tested. You may need an if let.
let range = sentence.range(of: "do")
Eric Witowski
Courses Plus Student 92 Pointsput this in xcode also showed me the same result in the pane but not in the console I see that both ways give the same results, thinking logically for future construts having the variable [range] can be useful in how many ways?
var sentence = "All boys do a really good cleaning"
sentence.range(of: "do")
Eric Witowski
Courses Plus Student 92 Pointsyes it worked also, really apologize I was in a rush and typed with my caps lock on. embarrassed.
Brandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsDefinitely is useful with search results for a table.
Eric Witowski
Courses Plus Student 92 PointsEric Witowski
Courses Plus Student 92 Pointswow, it is more simple than I imagine. thanks
Brandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsBrandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsDid it work?