Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trouble with conditional else

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    trouble with conditional else

    I have control code like below. All my prints are good. I can print breakfast, lunch, dinner. But I cant get the else to print go for a walk. What am i doing wrong? its like the else doesn't see the if's. Thanks all.

    if (bool1 true)
    {make breakfast}
    else if (bool2 true)
    {make lunch}
    else if (bool3 true)
    {make dinner}
    else
    {go for a walk}

    #2
    Hi Kicks.Spin, thanks for your post.

    The last else will only print if all the above ifs evaluate to false. Make sure all 3 booleans are false then go for a walk should show up.

    Best regards,
    -ChrisL

    Comment


      #3
      thank you ChrisL. the above ifs did evaluate to false. i got it. looks like i needed to bracket the else inside the if brackets.

      if (bool1 true)
      {
      {make breakfast}
      else if (bool2 true)
      {make lunch}
      else if (bool3 true)
      {make dinner}
      else
      {go for a walk}
      }
      Last edited by Kicks.Spin; 05-12-2021, 10:08 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      669 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      378 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      580 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X