Anonymous user
Array: Difference between revisions
→Smalltalk
Line 209:
===[[Smalltalk]]===
Smalltalk provides a rich set of collection classes in its base library, which is also standard (ANSI) among the different implementations.
Array, ByteArray, String and all
In Smalltalk, a character is exactly that: a character with a code point, not to be confused with a byte valued integer. Thus Strings and ByteArrays are different things (as opposed to eg. C language).
Array
Line 250 ⟶ 252:
a1 collect:#squared -> ditto
a1 count:[:e | e >= 20]. -> 3
a1 occurrencesOf:10 -> 10
.. there are many many more such functions..
"converting"
a1 asByteArray -> #[10 20 30]
#(200 300 400) asByteArray -> error raised
(#(65 66 67) collect:#asCharacter) asString -> 'ABC'
"searching"
Line 300 ⟶ 307:
d1 removeKey:'one'
d1 includesKey:'two' -> false. "is key present"
d1 includes:2 -> false. "is value present; attention: not O(1)"</lang>
Overall there are hundreds of methods implemented in Collection, from which all of the above inherit and which are not listed here.
[[Category:Data Structures]]
|