Created
April 7, 2022 17:02
-
-
Save trycf/a14e90f6775e943be73d643a1f44ef07 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
array function f(required array a) { | |
local.setInFunction = true | |
local.remappedArray = a.map((v) => v, true, 5) | |
local.sortedArray = local.remappedArray.sort((e1, e2) => { | |
local.setInSortCallBack = true | |
return e2 - e1 | |
}) | |
writeOutput("setInFunction should exist: " & local.keyExists("setInFunction") & "<br>") // CF returns false | |
writeOutput("setInSortCallBack should NOT exist: " & local.keyExists("setInSortCallBack") & "<br>") // CF returns true | |
writeDump(local) // it's the local from the sort callback, not this function! | |
return local.sortedArray | |
} | |
a = [4,3,2,1] | |
result = f(a) | |
writeDump(result) | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment