728x90 ๋ฐ์ํ ํค์๋๊ฒ์์๊ณ ๋ฆฌ๋ฌ1 [Swift] keyword๋ฅผ ์ด์ฉํด์ ๊ฒ์ํ๋ ๋ฒ ์ฝ๋๋ฅผ ๋ถ์ฌ๋ฃ์ ์ ์๋ค๋ ๊ฑธ ์ฒ์ ์์๋ค. let recipes = ["Put eggs in a frying pan", "Cut the beef", "Boil the beef"] let keyword = "beef" func search(recipes:[String],keyword:String) -> [String]{ var foundRecipes = [String]() for recipe in recipes{ if recipe.contains(keyword) == true { foundRecipes.append(recipe) } } return foundRecipes } var a = search(recipes: recipes, keyword: "egg") ๋ด๊ฐ ์๊ฐํ ํต์ฌ์ contains์ app.. 2019. 12. 5. ์ด์ 1 ๋ค์ 728x90 ๋ฐ์ํ