Lic - easy, safe object slicing for Swift
Lic is a μ-framework that makes getting slices of arrays and strings in Swift 2 safe and easy:
[0,1,2,3][1, -1] // => ArraySlice([1, 2]) "Hello"[-1000, nil] // => "Hello" [1,2,3,4,5,6,7,8][1,5][2,3] // => ArraySlice()
Lic has no dependencies, not even
Range Free Slices
To make a slice, you must give two indexes, indicating the start and end positions where the slice will be produced. Lic tries to make sense of the indexes following these rules:
- a negative index indicates a position counted in the reverse direction
nilis equivalent to the start or end index
- an out-of-bound index is treated as the same as start or end index, depending on which bound it goes beyond
- if the start index ends up at a position after the end index, Lic returns the empty value
When it comes to slicing, your ranges are always safe and accepted.
platform :ios, '8.0' use_frameworks! target 'MyApp' do pod 'Lic' end
Include the single source file in your project.
(There's no dependencies at all).
What kind of name is "Lic"?
"slice"[1,-1] - a slice of the word "slice", you know, what Lic produces.
BSD, see LICENSE