Welcome to the second Type | Treat challenge! Today we will be deriving the types of pumpkins and busting ghosts!
Yesterday's Solution
...
For further actions, you may consider blocking this person and/or reporting abuse
In the advanced/intermediate challenge. It states that
'Bobby Tables' cannot have peanutsbut to me, the solution seems to do the opposite and actually keep all the candies where there are peanuts 🤔I agree with your implementation. I was discussing the solution provided in this post :)
Maybe @gcrev93 can help me if I misinterpreted it
My bad, should have said something instead of just plopping down a solution - yes you are correct saying that:
is the opposite of the solution. Something more correct would have the inverted type. I'm not sure how one would go from
HasPeanutsto something likeOmitsPeanutsbut declaring it from scratch is straightforward:Also, the proposed solution for AllCandies removes all candies from the union, instead of only keeping the candies.
This should probably use
Extractinstead ofExclude:Bobby is on his way to the hospital now. Thankfully somebody had an epi-pen ready.
"The need to use [number] is an interesting twist, because [0] or 1 would have worked just as well too. Doing this right would also have raised the typo in the original code."
I'm confused by the wording here. So,
numberAND[0]or[1]would work? So, you don't actually have to usenumber?Yeah, you can use
numberor any literal like1,2,etc.In this case,
numberhowever feels more right, because you're saying any number from the index, not a specific one.Thanks! That makes sense.
Here is my attempt :)
If we aren't allowed to change
type Ghostsandfunction investigateReportwhich accepts an array ofGhosts, can we simplyreturn falsefor bothfunction areGodsandfunction areEctoplasmic?My implementation of
function areDemonsusing user-defined type guard:Not if you want to live... and save NYC.