❔ ✅ get unknown range of list to display?
this information is generated into a string like
string evidence = "EMF 5, Spirit Box, Ghost Writing";
. Knowing that it's not the same evidence every time, how can I cut off the last piece of evidence and display the first two?33 Replies
split the string on
,
and drop the last item?like this?
ugh, no
well this is how it's generated into a string....
well if you already have it as an array, isnt it better to just use the array then?
why convert to string, remove the last item, then convert back into array, to then convert to string again?
that seems insanely convoluted
😄
idk that's why I asked. This isn't python so it's confusing.....sorry. I don't mean to disappoint
so, this is an X Y problem
you're trying to solve X, your attempted solution is Y, so you're asking about Y
I need you to tell me about X
what is the actual problem you are trying to solve here?
ok you said it's already an array
ghost.Evidence
is, last time we talked
so if you have access to that, its much easier to work with that directlyso I should be able to do something like this then, right?
rather than the string version
uhm.. what do you think
string.Join
does?joins an array to a string
that's why I'm trying to index the array
right. and
ghost.Evidence
is an array, that we agree on
what is ghost.Evidence[0]
thou?
is that also an array?in the ghost model, it is done as an array.
then it's stored to the json file like so. When I pull it from the json file,
I do so like this to get it into a string that looks like
"EMF 5, Spirit Box, Ghost Writing"
so it's easier to print to the screen. I'm just trying to figure out how to drop the last item in the stringbut why in the string?
isnt the string literally just a display interpretation of the array?
you shouldn't be modifying the string, you should be modifying the array
and honestly, at that point, it shouldn't be an array, it should be a list
you're still focused on Y
tell me about X. why do you want to drop the last item from the string?