Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template cut(s: string, left: Natural = 0, right: Natural = 0): string =
- s[left .. ^(right + 1)]
- echo cut("Hello World", right = 6)
- echo cut("Hello World", left = 6)
- echo cut("Hello World", left = 4, right = 4)
- #[
- >nim c -r strslice.nim
- Hint: used config file 'C:\Program Files\Nim\config\nim.cfg' [Conf]
- Hint: used config file 'C:\Users\Fredrik\AppData\Roaming\nim.cfg' [Conf]
- Hint: system [Processing]
- Hint: strslice [Processing]
- strslice.nim(4, 9) Error: type mismatch: got (string, Slice[system.Natural])
- but expected one of:
- proc `[]`[Idx, T](a: array[Idx, T]; x: Slice[Idx]): seq[T]
- proc `[]`(s: string; x: Slice[int]): string
- proc `[]`[T](s: seq[T]; x: Slice[int]): seq[T]
- proc `[]`[I: Ordinal, T](a: T; i: I): T
- proc `[]`[Idx, T](a: array[Idx, T]; x: Slice[int]): seq[T]
- ]#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement