mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: add [..2]
& [2..]
support for slices
This commit is contained in:

committed by
Alexander Medvednikov

parent
e80cf185b9
commit
a075ce160e
@ -394,6 +394,12 @@ pub fn (s string) right(n int) string {
|
||||
return s.substr(n, s.len)
|
||||
}
|
||||
|
||||
// used internally for [2..4]
|
||||
fn (s string) substr2(start, _end int, end_max bool) string {
|
||||
end := if end_max { s.len } else { _end }
|
||||
return s.substr(start, end)
|
||||
}
|
||||
|
||||
// substr
|
||||
pub fn (s string) substr(start, end int) string {
|
||||
if start > end || start > s.len || end > s.len || start < 0 || end < 0 {
|
||||
|
Reference in New Issue
Block a user