How the answer is 2? I want Explaination. | SoloLearn: Learn to code for FREE!

+9

How the answer is 2? I want Explaination.

Here is the SS. I want to know how the answer is 2 and how count woks for array? https://www.sololearn.com/post/487122/?ref=app

php

8/7/2020 5:11:00 PM

AJ #👋👋👋👋👋

6 Answers

New Answer

+12

Here, true == 1, false == 0, therefore the last two assignments override the previous two, and finally array contains only two elements

+8

Yes, very sure, Namit Jain . AJ #L1G3 , this is because true == 1, false == 0, therefore the last two assignments override the previous two..., finally the array contains only two elements

+8

MiKoLa🔥3L17.4L16.2.5k=>L18 Ok got it. Here array contains objects so false will replaced by 0 and true will replaced by 1.

+7

true == 1 false == 0 So, We have only 2 terms🤔 Not sure👦

+5

AJ #L1G3 yes👦

+3

Dictionaries should have unique keys. Here true and 1 are the same so only one key is initialized. Same goes to false and 0. Thus it results in an array of length 2. Happy coding!