Last active
June 6, 2016 12:56
-
-
Save roryl/19296468d648117f1fb2 to your computer and use it in GitHub Desktop.
Lucee Struct Examples
This file contains hidden or 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
[submodule "database_session_storage"] | |
path = database_session_storage | |
url = https://gist.github.com/roryl/44f730ecd8ba2593b03e45f1189fcf5f |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
myStruct.insert("key", "value"); //struct now look like {foo:"one", bar:"two", baz:"three", key:"value"}; | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
echo(myStruct["foo"]); //outputs "one" | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {}; | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", | |
bar:"two", | |
baz:{ | |
key:"value" | |
} | |
}; | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = structNew("ordered"); | |
myStruct.insert("foo","one"); | |
myStruct.insert("bar","two"); | |
myStruct.insert("baz","three"); | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
dump(myStruct); | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {"foo":"one", "bar":"two", "baz":"three"}; | |
dump(myStruct); | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
myKey = "foo"; | |
echo(myStruct[myKey]); //outputs "one" | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
myStruct.each(function(key, value, structure){ | |
echo(key); //outputs "foo" then "bar" then "baz"; | |
echo(value); //outputs "one", then "two", then "three" | |
dump(structure) ; //A reference to the whole structure | |
}); | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
for(key in myStruct){ | |
echo(key); //outputs "foo" then "bar" then "baz"; | |
echo(myStruct[key]); //outputs "one", then "two", then "three" | |
} | |
</cfscript> |
This file contains hidden or 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> | |
myStruct = {foo:"one", bar:"two", baz:"three"}; | |
echo(myStruct.foo); //outputs "one" | |
</cfscript> |
This file contains hidden or 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
/** | |
* My xUnit Test | |
*/ | |
component extends="testbox.system.BaseSpec"{ | |
/*********************************** LIFE CYCLE Methods ***********************************/ | |
// executes before all test cases | |
function beforeTests(){ | |
} | |
// executes after all test cases | |
function afterTests(){ | |
} | |
// executes before every test case | |
function setup( currentMethod ){ | |
} | |
// executes after every test case | |
function teardown( currentMethod ){ | |
} | |
/*********************************** TEST CASES BELOW ***********************************/ | |
// Remember that test cases MUST start or end with the keyword 'test' | |
function checkAllSyntaxTest(){ | |
var files = directoryList(""); | |
for(file IN files){ | |
if(file CONTAINS ".cfm"){ | |
include template="#getFileFromPath(file)#"; | |
writeDump(file); | |
writeDump(myStruct); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment