How to return values from functions - Swift for Complete Beginners

Поділитися
Вставка

КОМЕНТАРІ • 17

  • @leonstone3443
    @leonstone3443 2 роки тому +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")

  • @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!

  • @justbe_joe9765
    @justbe_joe9765 Рік тому +1

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

  • @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!

  • @Minttusuklaarae
    @Minttusuklaarae 27 днів тому

    FIzzBuzz was a breeze but the identical letters-function humbled me

  • @NavDhillon
    @NavDhillon Рік тому

    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 Рік тому +1

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

    • @AdminAlley
      @AdminAlley 3 місяці тому

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

  • @AngryAyrab
    @AngryAyrab 5 днів тому

    function are really tripping me up

  • @Arnoboy93
    @Arnoboy93 2 роки тому +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