How to use Functions in Swift | Swift Basics #5

Поділитися
Вставка
  • Опубліковано 19 тра 2024
  • Learn the ins and outs of using functions in Swift with this comprehensive tutorial! Discover the power of modular programming and code reusability by mastering function creation and invocation. Understand the concepts of parameters and return values to enhance the functionality of your code. Gain the skills to break down complex tasks into manageable functions. Start your journey to becoming a proficient Swift developer today and unlock the full potential of functions in your code!
    🤙 WELCOME BACK 🤙
    WEBSITE: www.swiftful-thinking.com
    DISCORD: / discord
    GITHUB: github.com/SwiftfulThinking/
    SAY THANKS: www.buymeacoffee.com/nicksarno
    00:00 Functions
    00:00 Intro
    01:46 Welcome back!
    03:47 Functions
    05:15 Functions can call other functions
    07:17 Functions control access
    08:57 Returning data out of a function
    11:35 Control flow in functions
    13:21 Function parameters
    18:40 Control flow in functions
    24:02 Guard statements
    29:06 Calculated variables
    34:23 Wrapping up

КОМЕНТАРІ • 33

  • @HaoHu-xp5fg
    @HaoHu-xp5fg Місяць тому +2

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

  • @davidchong4721
    @davidchong4721 13 днів тому

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

  • @JuanFmTech
    @JuanFmTech 8 місяців тому +5

    amazing content, crazy this is free

  • @Eportal-bk1tk
    @Eportal-bk1tk 6 місяців тому

    Very helpful! thanks for the excellent free classes!🙂

  • @raquelcervantes3332
    @raquelcervantes3332 9 місяців тому +2

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

  • @unquestionabletv
    @unquestionabletv 10 місяців тому

    We’re back
    Again
    Welcome back

  • @violetanikolova769
    @violetanikolova769 9 місяців тому +4

    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  9 місяців тому +6

      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 🤙

  • @aaronq6952
    @aaronq6952 10 місяців тому +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 UA-cam. 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  10 місяців тому +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

  • @honey.badger
    @honey.badger 9 місяців тому

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

  • @vk1653
    @vk1653 2 місяці тому

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

    • @SwiftfulThinking
      @SwiftfulThinking  2 місяці тому +1

      I covered escaping closures here: ua-cam.com/video/7gg8iBH2fg4/v-deo.htmlsi=ySMPW4QBbHENDGFR
      But if you’re following these playlists in order, you don’t need to know that yet

  • @jbagglesworth
    @jbagglesworth 9 місяців тому

    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 9 місяців тому

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

  • @mikhailkonovalov3049
    @mikhailkonovalov3049 10 місяців тому

    awesome

  • @sujitmemane
    @sujitmemane 10 місяців тому

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

  • @AlexanderWebster_
    @AlexanderWebster_ 9 місяців тому

    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  9 місяців тому

      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

  • @ScottSchwartz-Owen
    @ScottSchwartz-Owen Місяць тому

    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!

  • @isocialize
    @isocialize 17 днів тому +1

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

  • @AnotherCG
    @AnotherCG Місяць тому

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

  • @911lalala
    @911lalala 10 місяців тому

    🎉🎉🎉

  • @liberiskermose9949
    @liberiskermose9949 17 днів тому +1

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

  • @chickenrei3876
    @chickenrei3876 10 місяців тому

    When will you make a video about Generics?

    • @SwiftfulThinking
      @SwiftfulThinking  10 місяців тому +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: ua-cam.com/video/rx3uRICZr5I/v-deo.html

    • @chickenrei3876
      @chickenrei3876 10 місяців тому

      @@SwiftfulThinking thanks 🙏

  • @sakshipatil9537
    @sakshipatil9537 10 місяців тому

    👌🏽👌🏽👌🏽

  • @guilhermemarques7564
    @guilhermemarques7564 Місяць тому +1

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

    • @SwiftfulThinking
      @SwiftfulThinking  Місяць тому

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

  • @hakantetik
    @hakantetik Місяць тому

    how appropriate to call a function before create it