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 SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      35 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      13 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      19 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      21 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X