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

  • Home
  • SEARCH
  • 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 6194633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:19:45+00:00 2026-05-24T03:19:45+00:00

this is a small portion of the code: @interface BOOL isCarryingmallet; @implementation -(BOOL)isCarryingWeapon {

  • 0

this is a small portion of the code:

@interface
BOOL isCarryingmallet;

@implementation

-(BOOL)isCarryingWeapon {
   return isCarryingMallet;
}

-(int)getWeaponDamage {
    if (isCarryingMallet) 
        return kVikingMalletDamage;
    else
        return kVikingFistDamage;
}

I don’t understand how this works. Does return isCarryingmMallet; return YES or NO? Why isn’t there an == YES in if (isCarryingMallet)? Why is it if (isCarryingMallet) not if (isCarryingWeapon).
Thanks for answering my newb questions!

  • 1 1 Answer
  • 0 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-24T03:19:46+00:00Added an answer on May 24, 2026 at 3:19 am

    The isCarryingWeapon method returns the value of the isCarryingMallet variable. If there were other possible weapons, that method could return a more complicated value, like (isCarryingMallet || isCarryingPlasmaCannon). Basically right now the only weapon that matters to this class is the mallet. When the isCarryingWeapon method is called, this class says to itself, “Am I carrying a mallet?” If so, it knows it’s carrying a weapon, so it returns true – “Yes, I’ve got a weapon.” Otherwise it returns false.

    As for the if question – all if statements do is determine whether the value in the parentheses evaluates to true or false. Equality statements are pretty common in if statements but they’re not at all required. More specifically, anything that is not 0, null, or nil is true. So the following will all execute the code in the curly braces:

    if (1) {...}
    if (37) {...}
    if (YES) {...}
    if (true) {...}
    

    Boolean variables are often named with the prefix is so that this makes natural grammatical sense. In your case, you can parse

    if (isCarryingMallet) {...}
    

    as

    If this guy is carrying a mallet, then…

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

Sidebar

Related Questions

I have this small code library that I'm considering releasing into Open Source. I
I've found this small code that sends email to gmail users. I'd like the
Work on this small test application to learn threading/locking. I have the following code,
I am considering porting a small portion of the code in a C# project
I've got this small question - given a bitmask of weekdays (e.g., Sunday =
I have this small SQL query. SELECT a.`id` , a.`title` , a.`date` , (
I have this small class called City that simply holds some information about a
We use this small utility method. But we don't like it. Since it's not
I'm building this small java applet in which I need a JPanel which will
I'm running this small C# test program launched from a pre-commit batch file private

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.