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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:08:39+00:00 2026-06-19T03:08:39+00:00

I have a nested struct like so struct1.struct2.foo . I would like to check

  • 0

I have a nested struct like so struct1.struct2.foo. I would like to check if foo exists. However, struct2 isn’t guaranteed to exists either. I loathe to use isDefined(), but I also think that calling structKeyExists() twice is wasteful (e.g., if (structKeyExists(struct, 'struct2') && structKeyExists(struct.struct2, 'foo')) {}

I thought about using structFindKey(), but then I don’t want to run into an issue if there exists struct1.foo

Is there a better way to accomplish this?

This is a similar question to this question, but I am not dealing with an XML document so most of the answers in that post doesn’t work for me.

  • 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-19T03:08:41+00:00Added an answer on June 19, 2026 at 3:08 am

    isDefined() could potentially return misleading results. It’s not as accurate as structKeyExists(). And unless you’re iterating through this code thousands of times at a pop, you won’t notice any performance difference. They both perform pretty well. But if the key doesn’t exist, that would be where you might notice the difference (again, only with thousands of iterations). isDefined() will traverse through the various available scopes if it can’t find it on the first pass. Even if you passed it a variable that looked like it specified the scope you wanted to check. structKeyExists() is pretty explicit in where it looks for that key. If it doesn’t find it, it will stop and return FALSE. It might look like you’re doing unnecessary work, but it’s returning a much more accurate result. And reading the code gives you a pretty good idea of what you’re looking for, so you don’t have to worry about it not being clean.

    Peter’s suggestion was a pretty good one. Check out that link.

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

Sidebar

Related Questions

I have nested iframes and I would like to use onload function for the
i have a nested struct and i'd like to have a pointer-to-member to one
I have recently started using boost::exception. Now I would like to use boost::errinfo_nested_exception to
In C, is it possible to have a struct nested within another struct? How
I would like a pattern for a nested private class in Objective C. Requirements
I have a struct nested winin a class and a union of that struct.
I would like to have a design suggestion from you. I have a set
I have a struct that's inside an array that is nested inside another struct,
I have nested list of the following form: my_list = [['Some1', '2', '3.6', '4.5',
What if I have nested loops, and I want to break out of all

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.