tracker issue : CF-3614459

select a category, or use search below
(searches all categories and all time range)
Title:

?.: safe navigation operator

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 08/19/2013

Components: Language

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 5

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 26, 2019 using build 2016.0.01.298513
See http://cfmlblog.adamcameron.me/2013/08/thinking-about-operators-in-cfml.html

This is best demonstrated with an example:

a = { b ={ c = { d = 1 } } }; writeOutput(a?.b?.c?.d); // 1 writeOutput(a?.e?.c?.d); // null writeOutput(a.e.c.d); // ERROR

So rather than erroring because a.e doesn't exist, it gracefully returns null. Nice. This saves a lot of sequential structKeyExists() calls, or (grim) an isDefined() call. 

-- 
Adam

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3614459

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

This would make big structures much easier to handle when you dont know which parts exist.
Vote by External U.
14708 | August 20, 2013 03:43:20 AM GMT
yes yes yes yes this! please!
Vote by External U.
14709 | December 11, 2014 02:31:40 PM GMT
Please re-triage for CF12.
Comment by External U.
14702 | June 20, 2015 05:12:37 AM GMT
+1000000 to this. Also here's some more text.
Vote by External U.
14710 | June 20, 2015 09:16:31 PM GMT
"The key to a happy life is to accept you are never actually in control." - Masrani, Jurassic World
Vote by External U.
14711 | June 20, 2015 10:36:08 PM GMT
So this is already done? When will it be released?
Comment by External U.
14703 | June 22, 2015 12:06:52 AM GMT
Hello again, Adobe. Any chance of an answer to that question I asked almost three months ago?
Comment by External U.
14704 | September 14, 2015 08:12:55 AM GMT
+1 ......................
Vote by External U.
14712 | September 14, 2015 01:40:30 PM GMT
+1 to Adam's request. Could "Fixed In Build" please be populated? Thanks!, -Aaron
Comment by External U.
14705 | September 14, 2015 02:42:46 PM GMT
Also note as part of this a ?[] operator also needs to be implemented, given the way one can reference object elements via dot ot array notation.
Comment by External U.
14706 | September 24, 2015 04:19:02 AM GMT
Adobe, Please allow the following, for checking if the right-hand operand is NULL: e = variables.?a.?b.?c.?e; Thanks!, -Aaron
Comment by External U.
14707 | October 23, 2015 11:36:09 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513), well except for array notation ?[]. Thanks!, -Aaron
Comment by Aaron N.
31216 | August 26, 2019 05:04:53 AM GMT