+ 1

(Ruby) Why size = 8?

So I made an array, I understand the reason of some of the sizes, except those which output 8 Here is the code. https://code.sololearn.com/cQ50F1U3tm3B/?ref=app

12th Feb 2020, 8:56 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
2 Antworten
+ 1
tab[0], tab[1] and tab[2] contain variables of the class Integer. Integer has a method called size which according to the documentation: "Returns the number of bytes in the machine representation of int (machine dependent)."
12th Feb 2020, 9:36 AM
Dennis
Dennis - avatar
0
So they are returning the size of type int, as they are a single integer? It makes sense. Thank you.
12th Feb 2020, 10:01 AM
Fernando Pozzetti
Fernando Pozzetti - avatar