+1 vote

Hello, community!

I'm using the new .erase feature and found an odd behaviour. Maybe it's me.

The scenario is that I'm asking a checklist question with the option to answer "Others". If the user selects that, it opens a *multiple type of answer for the user to add his other options.

Thus, I'd like to have 3 collections:

  • One with the original selection (including "others")
  • One with what the user added in the *multiple question
  • One consolidated collection, but without the "others" element in it.

Thus, what I tried, is to create a new collection based on the original one. Erasing the "others" element and adding the "others" collection. Here's an example:

*question: Which letter do you like?
*throwaway
*type: checkbox
*save: results_original
A
B
C
Others

*if: "Others" in results_original
	*question: Which other letters do you like?
		*throwaway
		*multiple
		*save: results_other
		
Original *before* erase from full: {results_original}

>>results_full = results_original
>>results_full.erase("Others")
>>results_full.add(results_other)

Original *after* erase from full: {results_original}
Other: {results_other}
Full: {results_full}

However, what I found is that the results_original collection also don't have the "others" element in it. Here's a sample result.

Original before erase from full: A, B, Others

Original after erase from full: A, B, X, Y
Other: X, Y
Full: A, B, X, Y

I find this odd, because I'm applying the .erase to the results_full collection, but it seems to be changing the results_original as well.

Perhaps the = assignation doesn't create a new list with just the values, but assigns another name to the same list?
Any help or insights here would be greatly appreciated!

by (440 points)

1 Answer

+1 vote
Best answer

Hi!
Do this instead:

>>resultsFull = [] 
>>resultsFull.combine(resultsOriginal)

You can find the full explanation for it in the manual:
https://docs.google.com/document/d/1RKblBEwG7BrMMeTXFITSNDJQsszHotqaE_q-E9q0QHA/view#heading=h.ds7raeq957xu

by (3.6k points)
selected by

It worked perfectly, thanks!

Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users