How to use Functions in Swift | Swift Basics #5

Поделиться
HTML-код
  • Опубликовано: 12 янв 2025

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

  • @ecrsbux1719
    @ecrsbux1719 Месяц назад +5

    Please add a supplementary video of Actors in the Basics of Swift Course because now functions are not accessing the global variables within their blocks without identifying the Actor so it will be helpful for the beginners to understand what the Actors are and what do they do at this stage respect to the functions usage.

  • @JuanFmTech
    @JuanFmTech Год назад +14

    amazing content, crazy this is free

  • @matthew_cramer
    @matthew_cramer 26 дней назад

    Thank you Nick, you are the best :) SwiftBasics --> Basic Types --> Variables --> Operators --> f(x)... I am super excited for Optionals.

  • @LOVEMUSIC-vp8xq
    @LOVEMUSIC-vp8xq 3 месяца назад +3

    I love your teaching style

  • @HaoHu-xp5fg
    @HaoHu-xp5fg 8 месяцев назад +6

    Your video has ability to let me feel exciting to forget to sleep.

  • @davidchong4721
    @davidchong4721 8 месяцев назад +1

    Great content. Finally I'm understanding some concepts that was so hard for me!

  • @Eportal-bk1tk
    @Eportal-bk1tk Год назад +2

    Very helpful! thanks for the excellent free classes!🙂

  • @liberiskermose9949
    @liberiskermose9949 8 месяцев назад +1

    @19:32. Doesn't swift infer from the parameter name that the return value type should be of type bool instead of void?

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

    We’re back
    Again
    Welcome back

  • @aaronq6952
    @aaronq6952 Год назад +3

    Hi Nick, thanks for those awesome video content! I have been watching your videos for a month now and I like your videos and coding style the most among all other videos on RUclips. Now I have some trouble when I try to practice my own app. I wonder if you are open for giving personal tutoring lessons.

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

      Hey! Thanks for the comment but I’m not doing personal lessons right now bc I want to keep making more videos for everyone. If you need help, someone in our discord will help: discord.gg/vhKKyYTGDb

  • @raquelcervantes3332
    @raquelcervantes3332 Год назад +4

    you kinda sound like Mordacai from the regular show lmao, appreciate your videos so much

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

    Hi Nick! Quick question, at 31:20 on line 117 of your code why did you change "value1" and "value2" to "Number1" & "Number2"? ...Why not just type Number1 & Number2 in the first place? Sorry for such a basic question but it confused me so much when small changes like that are made and I don't understand the reasoning behind the change. Thanks in advance!

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

      Yeah it's definitely confusing. I think Nick is demonstrating "named parameters" . They're like labels for parameters to make code easier to read

  • @knkrmn
    @knkrmn 4 месяца назад

    Great video. Thank you

  • @violetanikolova769
    @violetanikolova769 Год назад +5

    Hi Nick! Thanks for this amazing content! Indeed ,your teaching style and diction, and explanations are absolutely great and makes it really easy for people like me (with no prior knowledge to programming) to follow the lectures.
    However, as I am a more visual person and it is always a lot easier for me to remember and grasp concepts more easily when I see it, do you think there is any way of integrating the Xcode and visualising what you are teaching on the screen with the iphone, where you actually see how your code changes the screen of the iphone.? Even if it is at this very beginners level - it would be so much easier to "see" waht we are doing.
    I follow the lectures and really enjoy them, but at some point if there isn't a visual break to actually see and feel how it is applied to the app I get somehow fatigue from just "pure programming." I am sure there are other people like me and integrating some visualisation would help them as well.
    I hope all this makes sense to you and it would help you make your amazing lectures even better!
    Regards,
    Villy

    • @SwiftfulThinking
      @SwiftfulThinking  Год назад +7

      Hey! This playlist is an intro to the Swift language, which doesn’t involve building a screen (it is just a coding language). The next playlist is the “SwiftUI Bootcamp” which is learning how to build screens and is 100% visual. Every video in that playlist involves seeing your code on screen 🤙

  • @saim4556
    @saim4556 7 месяцев назад

    thanks for the video mate..

  • @marcelolewin
    @marcelolewin 7 месяцев назад

    Is there a performance improvement using guard vs. if else? Also, what's a realistic use of calculated variables? Great videos and series! Thanks for doing this!

    • @swiftodyssey
      @swiftodyssey 3 месяца назад

      @marcelolewin performance-wise, both approaches are equally efficient. However, using guard is often preferred when validating input or unwrapping optionals because it avoids deep nesting as is possible with multiple if & if-else conditions, making the code easier to read. This is also commonly called early exit which makes the guard like a gatekeeper. It also improves readability to an extent.
      For example you may have an if statement that first checks if the user bought a ticket for a movie, then check if the movie plays at a given theater, then check if the showtime is nearing etc etc which would have nested if's within if's. With guard you could have each check separately such as guard userHasTicket, then check guard moviePlaysAtTheater, then check guard showTimeIsNotOver etc.. It'll make more sense if you write these down to see the benefit.
      Coming to calculated or computed properties, as Nick said you could use them to provide derived data. For example, if you had a Struct or Class for a Rectangle that took width & height parameters, you could have a computed property that calculated the area of the rectangle and do something with it. These are handy as they will always use the latest state or value of width & height. They are also useful when you aren't returning multiple values as a function would or throwing errors for example or executing complex logic. So basically when the property is a function of the state. Do note that when using autocomplete for example, it may seem that width, height & area (as a computed property) are variables in equal sense when in fact, area depends on width & height. I use computed properties when they are just that i.e. properties doing simple things (like with area); and use functions for more complex & intensive logic execution. Hope this helps!

  • @vk1653
    @vk1653 10 месяцев назад

    Thanks for the amazing videos, are you going to do a video on closuers

    • @SwiftfulThinking
      @SwiftfulThinking  10 месяцев назад +1

      I covered escaping closures here: ruclips.net/video/7gg8iBH2fg4/видео.htmlsi=ySMPW4QBbHENDGFR
      But if you’re following these playlists in order, you don’t need to know that yet

  • @PKperformanceEU
    @PKperformanceEU Месяц назад

    Please use AIDente for the sake of your laptops battery, keep it at 80% limit or perhaps 70% when its just sitting on your desk

  • @ScottSchwartz-Owen
    @ScottSchwartz-Owen 8 месяцев назад

    Nick, because we are making new playgrounds for each lesson within the same file, how do you have Xcode only run the code we wrote in the current playground? Xcode is building the entire project when I run it, even when only running by clicking the blue arrow below the code, but its still pulling in code from every file and module and displaying the previous lesson print statements in every subsequent lesson... thanks!

    • @tobias6861
      @tobias6861 6 месяцев назад +1

      You can click the trash icon on the bottom right of the screen

  • @isocialize
    @isocialize 8 месяцев назад +1

    Hold the option button thing does not work on my computer.

  • @honey.badger
    @honey.badger Год назад

    how do you get the info when you hi-light/hold mouse over the word?

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

    Is it aloud to access the function before declaring in swift ?

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

    so, inside my function my variables that I created before my function are not auto-populating like yours are in your video. Do you know why this might be? It makes me go a little slower, and I don't want this to be a bad habit for the rest of my coding career.

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

      I’m not sure what you’re doing different but I’m sure the behavior of functions hasn’t changed haha if you want to share your code someone can help you in our discord: discord.gg/uaRRJeGbFc

  • @SIGMA_UNITE
    @SIGMA_UNITE Месяц назад

    where can i donate

  • @guilhermemarques7564
    @guilhermemarques7564 8 месяцев назад +1

    In calculated variables, why you didn't use Double? I thought you would use Double for math.

    • @SwiftfulThinking
      @SwiftfulThinking  8 месяцев назад

      Yea double is good if you need decimals in the calculation. Sometimes for simple math, you can use Int

  • @PrivatePerson-pu7hv
    @PrivatePerson-pu7hv 5 месяцев назад +1

    Why do you keep calling the function body: "closure"? Isn't closure a different type of statement?

  • @saim4556
    @saim4556 7 месяцев назад

    when i am pressing option button and clicking on name its showing : No Quick Help

    • @AshShawwa
      @AshShawwa 2 месяца назад

      Closing Xcode and reopening fixed it for me

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

    When will you make a video about Generics?

    • @SwiftfulThinking
      @SwiftfulThinking  Год назад +2

      I have a video on Generics but it’s not covered in this playlist because it’s a much more advanced topic that beginners don’t need to know yet. You can watch it here: ruclips.net/video/rx3uRICZr5I/видео.html

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

      @@SwiftfulThinking thanks 🙏

  • @AnotherCG
    @AnotherCG 9 месяцев назад

    I knew the frowning upon and shaming global variables with pop-up. Shaking my head

  • @hakantetik
    @hakantetik 9 месяцев назад

    how appropriate to call a function before create it

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

    awesome

  • @911gogogo
    @911gogogo Год назад

    🎉🎉🎉

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

    👌🏽👌🏽👌🏽