Skip to content

Commit

Permalink
Add API docs for StaticArray
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Jul 17, 2018
1 parent 249a2ed commit c2aa4a9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/static_array.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
# A fixed-size, stack allocated array.
#
# `StaticArray` is a generic type with type argument `T` specifying the type of
# its elements and `N` the fixed size. For example `StaticArray(Int32, 3)`
# is a static array of `Int32` with three elements. This type can also be
# expressed as `Int32[3]` (only in type grammar).
#
# ```
# StaticArray(Int32, 3).new(42) # => StaticArray[42, 42, 42]
# StaticArray(Int32, 3).new { |i| i * 2 } # => StaticArray[0, 2, 4]
# StaticArray[0, 8, 15] # => StaticArray[0, 8, 15]
# ```
#
# For number types there is also `Number.static_array` which can be used to initialize
# a static array:
#
# ```
# Int32.static_array(0, 8, 15) # => StaticArray[0, 8, 15]
# ```
#
# The generic argument type `N` is a special case in the type grammar as it
# doesn't specify a type but a size. It's value can be an `Int32` literal or
# constant.
struct StaticArray(T, N)
include Indexable(T)

Expand Down

0 comments on commit c2aa4a9

Please sign in to comment.