Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
hitko15462yVarying 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.
Mitiko66452yArray has . Length and List has .Count
But they both have a .Count(predicate<object>) method
It's weird but you get used to it
Don't forgot lua's # operator.
My favourite in this way is trimming white spaces from string (trim vs strip) - I never get it right on first try...
TRex10712ywhere's is the super-upvote button. anyone?
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);
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) in the function, but it will divide the pointer width of the architecture by the size of the underlying type, which is usually nonsense.
Root634682yI never remember random functions.
karma108181yWrong image, we all agreed this was the new gender selection component!!!
Can we all agree that .__len__() is the worst one
jak64516871yEach time i switch language XD