Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 509667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:02:04+00:00 2026-05-13T07:02:04+00:00

I just want to know what the difference between all the conditional statements in

  • 0

I just want to know what the difference between all the conditional statements in objective-c and which one is faster and lighter.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:02:04+00:00Added an answer on May 13, 2026 at 7:02 am

    The language-agnostic version (mostly, obviously this doesn’t count for declarative languages or other weird ones):

    When I was taught programming (quite a while ago, I’ll freely admit), a language consisted of three ways of executing instructions:

    • sequence (doing things in order).
    • selection (doing one of many things).
    • iteration (doing something zero or more times).

    The if and case statements are both variants on selection. If is used to select one of two different options based on a condition (using pseudo-code):

    if condition:
        do option 1
    else:
        do option 2
    

    keeping in mind that the else may not be needed in which case it’s effectively else do nothing. Also remember that option 1 or 2 may also consist of any of the statement types, including more if statements (called nesting).

    Case is slightly different – it’s generally meant for more than two choices like when you want to do different things based on a character:

    select ch:
        case 'a','e','i','o','u':
            print "is a vowel"
        case 'y':
            print "never quite sure"
        default:
            print "is a consonant"
    

    Note that you can use case for two options (or even one) but it’s a bit like killing a fly with a thermonuclear warhead.

    While is not a selection variant but an iteration one. It belongs with the likes of for, repeat, until and a host of other possibilities.

    As to which is fastest, it doesn’t matter in the vast majority of cases. The compiler writers know far more than we mortal folk how to get the last bit of performance out of their code. You either trust them to do their job right or you hand-code it in assembly yourself (I’d prefer the former).

    You’ll get far more performance by concentrating on the macro view rather than the minor things. That includes selection of appropriate algorithms, profiling, and targeting of hot spots. It does little good to find something that take five minutes each month and get that running in two minutes. Better to get a smaller improvement in something happening every minute.

    The language constructs like if, while, case and so on will already be as fast as they can be since they’re used heavily and are relative simple. You should be first writing your code for readability and only worrying about performance when it becomes an issue (see YAGNI).

    Even if you found that using if/goto combinations instead of case allowed you to run a bit faster, the resulting morass of source code would be harder to maintain down the track.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to know the difference between List<string> lst = new List() and
I just want to know what is the actual difference between private and protected
I just want to know what is the difference between these two messaging constants.
I just want to know if is possible to calculate the diference between two
I just want to know how to code a animation like the one on
Just want to know if publishing an application on Google play is allowed using
Just want to know how to read an attribute of a parent node from
I just want to know why both the paint and draw methods are used
i just want to know, how to write Code behind(Hyperlink1_Click()), for the hyper link
I just want to know how to access an array in SMARTY that have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.