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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      57 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      78 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      41 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      101 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      61 views
      0 likes
      Last Post PaulMohn  
      Working...
      X