gama.old icon indicating copy to clipboard operation
gama.old copied to clipboard

Wrong result with the "split_with(string ...)" operator

Open ptaillandier opened this issue 3 years ago • 6 comments

Describe the bug Test the following expression: write "333%444" split_with "%%";

It should returns a list composed of only one element ["333%444"]. Instead GAMA returns ['333','444']

Desktop (please complete the following information):

  • GAMA version: git, 1.8.2

ptaillandier avatar Mar 01 '22 04:03 ptaillandier

Actually no. If you look at the doc, it rightly says : Returns a list containing the sub-strings (tokens) of the left-hand operand delimited by each of the characters of the right-hand operand To use the whole string as a delimiter, you have to use the second form of split_with with a boolean argument set to true. i.e: write "333%444" split_with ("%%", true);

AlexisDrogoul avatar Mar 02 '22 15:03 AlexisDrogoul

Very interesting. However, for me, the default behavior should be "333%444" split_with ("%%", true) to be consistent with older versions of GAMA and because it seems to be a lot more natural for modelers who are not computer scientists :) .

ptaillandier avatar Mar 03 '22 02:03 ptaillandier

Should I mention who implemented this operator like this in 2018 ?? 🤣

(https://github.com/gama-platform/gama/commit/c9d2a09186ebc2bb9b2fb74588bd54f4c4f4d48e)

AlexisDrogoul avatar Mar 03 '22 03:03 AlexisDrogoul

2018 .... it is very recent considering the long history of GAMA 😅

Le jeu. 3 mars 2022 à 10:09, Alexis Drogoul @.***> a écrit :

Should I mention who implemented this operator like this in 2018 ?? 🤣

(c9d2a09 https://github.com/gama-platform/gama/commit/c9d2a09186ebc2bb9b2fb74588bd54f4c4f4d48e )

ptaillandier avatar Mar 03 '22 03:03 ptaillandier

Maybe. But the important thing to consider is the who ^^

AlexisDrogoul avatar Mar 03 '22 03:03 AlexisDrogoul

So I let you decide whether to close it or change your implementation 😀

AlexisDrogoul avatar Mar 03 '22 07:03 AlexisDrogoul

Let's close this issue -- everything works as intended !

AlexisDrogoul avatar Dec 18 '22 07:12 AlexisDrogoul