What is an If Statement? (C# vs Python)

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

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

  • @felixdepuiseau5756
    @felixdepuiseau5756 5 лет назад

    love your basic videos!

  • @iezzicamilo
    @iezzicamilo 4 года назад +1

    if (true)?
    i don't understand, if WHAT is true? is true a variable? shouldn't there be a "bool true = true" before? IM CONFUSE
    why does the block of code run when issuing an if (true)? how does it know true is true? shouldn't there be an assigned value to 'true'?

    • @Jabrils
      @Jabrils  4 года назад +3

      So take a step back real quick. Remember the variables episode to understand what is going on. You can think of a variable as a gift wrapped birthday present that stores something, in this case, it stores a Boolean value. Now booleans only have 2 values (in most languages) which is a true value, or false value, no matter what you name your variable, in the end it will either be true or false.
      & So with that, if you look at an if statement as a friend, you can give them your Boolean value gift wrapped, aka in a form of a variable, OR you can decide to not gift wrap it, & just give them their gift unwrapped & exposed, aka, explicitly writing true or false.
      Last note, when compile, true is always true, false is always false. Nothing changes when you wrap the value into a variable. If something is true, then run the code in the block, if not true, then of course, don't run the block. It's just how logic works.

    • @iezzicamilo
      @iezzicamilo 4 года назад

      @@Jabrils thanks man! this helped, especially the last paragraph

  • @BkSMedia
    @BkSMedia 5 лет назад +1

    Ok, so I got the jist of it, BUT, what if (pun intended), I wanted the FALSE value to actually do something? You've shown in the video that "if False" nothing will be output, what if I actually want it to output a value or a variable? 🤔

    • @BoomBunny
      @BoomBunny 5 лет назад

      That's a really good question, now I'm curious lol.

    • @israelc5320
      @israelc5320 5 лет назад

      Well my guess is that The Boolean has to be either true or false, so that would mean that you have to make the Boolean be true when the output is false.

    • @bananamaster360
      @bananamaster360 5 лет назад

      You would have to type an "Else" statement. (next video in the playlist) ☺

    • @eijstech
      @eijstech 5 лет назад +1

      if(!true)
      {//Do something}
      else {//Do not do something}
      ! should be read as "if not" - in this case "so if not true, do this!"

  • @BoomBunny
    @BoomBunny 5 лет назад +1

    do you need to have a boolean in the brackets?

    • @Jabrils
      @Jabrils  5 лет назад +1

      No any statement can go into the brackets of an if statement 🙂
      - Jabril

    • @BoomBunny
      @BoomBunny 5 лет назад +1

      @@Jabrils ok!! Thank you! :D

  • @Sparagas
    @Sparagas 3 года назад

    You could write PASS