Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
hitko31486yVarying syntax aside, fixed data structures like strings & arrays are generally implemented as a continuous block of memory with certain LENGTH. Other data structures, like sets and dictionaries, are commonly implemented as linked cells (either flat, or in a tree-like structure). For those types, you usually have multiple sparse blocks of memory, so you have either COUNT nodes, or a tree with certain SIZE.
-
Mitiko63556yArray has . Length and List has .Count
But they both have a .Count(predicate<object>) method
It's weird but you get used to it -
My favourite in this way is trimming white spaces from string (trim vs strip) - I never get it right on first try...
-
In C, sizeof and len mean different things. Sizeof gives you the size of an array in bytes, possible padding included. The idiomatic usage of length however refers to the maximum element count, and that's only the same as sizeof for arrays of byte type.
If you want to get the length of an array regardless of its underlying type, the expression is even weirder:
len = sizeof(arr)/sizeof(arr[0]);
But here comes the next fun part, when you hand over an array to a function, the function only sees a pointer without array length information, so you have to supply it as separate function parameter.
The final fun thing is that you can still use sizeof(arr_ptr)/sizeof(arr_ptr[0]) in the function, but it will divide the pointer width of the architecture by the size of the underlying type, which is usually nonsense. -
Root825416yI never remember random functions.
rand
rand()
Rand
random
random()
RND
RNG
randInt
Random.new()
new Random()
Math.random()
...
Related Rants
How language creators choose the function to get the size of an array..
I mean, the life could be more simple, this is just an example.
joke/meme
shit
size
array
tag in a tag
standards