How to return values from functions - Swift for Complete Beginners

Поделиться
HTML-код
  • Опубликовано: 4 сен 2024
  • Other videos in the Functions section:
    1. How to reuse code with functions: • How to reuse code with...
    2. How to return values from functions: This video
    3. How to return multiple values from functions: • How to return multiple...
    4. How to customize parameter labels: • How to customize param...
    5. How to provide default values for parameters: • How to provide default...
    6. How to handle errors in functions: • How to handle errors i...
    7. Summary: Functions: • Summary: Functions - S...
    8. Checkpoint 4: • Checkpoint 4 - Swift f...
    You can find the full set of videos, along with transcriptions, challenges, tests, and more, in my free 100 Days of SwiftUI course: www.hackingwit...
    Watch the full Swift for Complete Beginners playlist here: • Swift for Complete Beg...

Комментарии • 15

  • @leonstone3443
    @leonstone3443 Год назад +1

    i mostly watch through your site but had to come here and give a sub and some likes! Appreciate all this knowledge! Hope i stick with this lol

  • @cristianooliveiralopes5530
    @cristianooliveiralopes5530 2 года назад +3

    import Cocoa
    func sameLetters(str1: String, str2: String) -> Bool {
    if str1.sorted() == str2.sorted() {
    return true
    } else {
    return false
    }
    }
    sameLetters(str1: "amor", str2: "roma")

  • @justbe_joe9765
    @justbe_joe9765 11 месяцев назад +1

    func checkString(string1: String, string2: String) -> Bool {
    return string1.sorted() == string2.sorted()
    }
    let wording = checkString(string1: "word", string2: "drown")
    print(wording)

  • @Socko973
    @Socko973 Год назад +1

    Interesting that you don't need to add an explicit return for the inner function ie. Int.random() or sqrt(). Feels weird coming from JS!

  • @Vidadlaur
    @Vidadlaur Год назад

    ESPAÑOL: Muy buena esa manera de una sola línea de código, cómo no lo vi antes? jaja.
    Yo lo hice así:
    func compareWords(word1: String, word2: String) -> Bool { //Declaro la función con 2 parámetros -> devuelve Bool
    let comparative = word1.sorted() == word2.sorted() ? true : false //Toda la condición aquí
    return comparative //Devuélveme lo que valga comparative
    }
    ¡Gracias por el contenido!

  • @NavDhillon
    @NavDhillon 11 месяцев назад

    Single line code without return is
    sqrt(a * a + b * b)

  • @HarshDuggal
    @HarshDuggal 2 года назад +1

    func isBothStringsSame(a: String, b:String) ->BOOL{
    if a.count != b.count{return false}
    else{ a.sorted() == b.sorted(){return true}
    }

    • @subarnakhorshed8112
      @subarnakhorshed8112 2 года назад +1

      not working.

    • @beginagain2296
      @beginagain2296 2 года назад

      func containsSameLetters (firstStr: String, secondStr: String) -> Bool{
      firstStr.lowercased().sorted() == secondStr.lowercased().sorted()
      }

  • @faQall
    @faQall Год назад

    I really want to be able to learn coding. But I'm starting to be afraid I'm just too stupid :D

    • @AdminAlley
      @AdminAlley День назад

      Fellow dummy here. Keep at it! Repetition is key.

  • @Arnoboy93
    @Arnoboy93 Год назад +1

    func areWeTwins(string1: String, string2: String) -> Bool {
    return string1.lowercased().sorted() == string2.lowercased().sorted()
    }
    let sameOrNot = areWeTwins(string1: "IamLordVoldemort", string2: "TomMarvoloRiddle")
    print (sameOrNot)

  • @cagataycetinkol7730
    @cagataycetinkol7730 2 года назад

    Sür topu, çek şutu, at golü, her gören aklına kaybedicekk
    Sakatsın iki ay blaketen, bu durum beni mahfedicek!
    Sen her gölün ayrı bi zevk, Harry Kane Harry Kane Harry Kane,
    Seni istiyorum hucümda her maç, bu durum beni mahvedicek!
    Eyy