gavinbaumanis
10/12/2022, 10:32 AMthis.currentPath = getDirectoryFromPath(getCurrentTemplatePath());
this.delim = find("/", this.currentPath) ? "/" : "\";
this.basePath = listDeleteAt(this.currentPath, listLen(this.currentPath, this.delim), this.delim);
this.mappings["/coldspring"] = "#this.basePath#/cfmapping/coldspring/";
Which is fine and works great...
But I have just installed testBox and it comes with its own Application.cfc - which I know I can do without... I don't need it - but as a default its application.cfc comes with similar code for creating the mappings... again all fine - but it is off by one directory.
The very short version of all this is I would like to propose a new function for getting the "parent" directory - which would effectively just be - in CFML
listDeleteAt(this.currentPath, listLen(this.currentPath, this.delim), this.delim);
Thoughts?dswitzer
10/12/2022, 12:11 PMlistPop()
function. I was always a bit surprised that ACF added listRest()
without a corresponding function to return a list without the last element.
So:
listPop(this.currentPath, this.delim);
Would be the same as:
listDeleteAt(this.currentPath, listLen(this.currentPath, this.delim), this.delim);
At least then you have a generic function for just returning a list without the last item. It's not specific for directories.zackster
10/12/2022, 12:28 PMzackster
10/12/2022, 12:32 PMzackster
10/12/2022, 12:43 PMzackster
10/12/2022, 12:48 PMAdam Cameron
pop
would return the element, not the new list. Was gonna suggest that until I noticed that. But I would def go for an idiomatic approach to removing an item from a list as a generic treatment of this, more than I would get behind another path-monkeying function.Adam Cameron
dropLast
function (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/drop-last.html). Python has a del
statement which deletes the n
th element from a list, but isn't a function so isn't quite the same. Can't see an equiv in PHP, Java, C#, Ruby
However Kotlin's dropLast
(from the back) is paired with drop
(from the front).gavinbaumanis
10/12/2022, 3:01 PMmoreMoreNumbers = [ ];
dump( ArrayPop( moreMoreNumbers, 44 ) ); // Outputs 44
dump( moreMoreNumbers ); // Outputs []