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 8103509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:34:05+00:00 2026-06-05T23:34:05+00:00

I have an object that returns a value if successful and false (or nil)

  • 0

I have an object that returns a value if successful and false (or nil) if it failed.

i want to assign that value to a variable

if(var1 = [object foo])
{
    //if the [object foo] returned a variable, goes here
}
else
{
    //[object foo] returned FALSE (or nil), go here
}

can an If statement detected if an assignment was valid?

  • 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-06-05T23:34:07+00:00Added an answer on June 5, 2026 at 11:34 pm

    Not sure I understand your question, but let me try and explain a few situations you can check

    1) Property contains value

    if ([object foo])
    {
        // If foo has a value associated to it that is not nil/false/zero
    }
    else
    {
        // If foo equals nil, false or zero
    }
    

    2) Assignment to a variable was successful

    if ((bar = [object myMethod]))
    {
        // If myMethod returns any non-nil value
    }
    else
    {
        // If myMethod returns nil
    }
    

    3) Previous assignment of a variable was successful

    bar = [object myMethod];
    
    if (bar)
    {
        // If bar has a value associated to it that is not nil/false/zero
    }
    else
    {
        // If bar equals nil, false or zero
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object with a method that returns a filehandle, and I want
I have a LINQ query that returns some object like this... var query =
I have a Linq query that returns an object of the type IQueryable<ClassX> .
I have a basic web service that returns the following object as JSON: public
I have method that returns Drawable , and if its Bitmap object is recycled
I have an ASP.NET WebService that returns an object of List public class Students
I have a controller method that returns a jSON object and in one calling
I have a web service that returns the binary array of an object. Is
I have an API that returns a promise from a deferred object. The problem
I have an object that I printed with Data::Dumper : $VAR1 = { 'record'

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.