What’s the difference between Array{Bool} and BitArray in Julia and how are they related?

An Array{Bool} stores each true/false value as a Bool, which is represented internally as a UInt8. So if your array has N elements, it will take N bytes to store it. A BitArray stores each true/false value as a single bit, with (conceptually) 8 of them packed into a single UInt8. Consequently, it takes only … Read more

How do you create an immutable array in Swift?

This has changed with Xcode 6 beta 3. While arrays used to be semi-mutable, as you describe, with their elements changeable but their length fixed, now immutable arrays share the same value semantics as Dictionaries: From the Xcode 6 beta 3 release notes: • Array in Swift has been completely redesigned to have full value … Read more

Why use arrays instead of slices?

As said by Akavall, arrays are hashable. That means they can be used as a key to a map. They are also pass by value. Each time you pass it to a function or assign it to another variable it makes a complete copy of it. They can be serialized by encoding/binary. They also can … Read more

tech