mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
arrays.range(min, max)
This commit is contained in:
parent
96f7620628
commit
aa39451c8b
10
vlib/arrays/arrays.v
Normal file
10
vlib/arrays/arrays.v
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module arrays
|
||||||
|
|
||||||
|
fn range<T>(start, end T) []T {
|
||||||
|
mut res := [T(0)]
|
||||||
|
for i := start; i < end; i++ {
|
||||||
|
res << i
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
10
vlib/arrays/arrays_test.v
Normal file
10
vlib/arrays/arrays_test.v
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import arrays
|
||||||
|
|
||||||
|
fn test_range() {
|
||||||
|
/*
|
||||||
|
TODO
|
||||||
|
a := arrays.range(1, 10)
|
||||||
|
assert a[0] == 1
|
||||||
|
println(a)
|
||||||
|
*/
|
||||||
|
}
|
@ -1641,9 +1641,10 @@ fn (p mut Parser) name_expr() string {
|
|||||||
p.error('enum `$enum_type.name` does not have value `$val`')
|
p.error('enum `$enum_type.name` does not have value `$val`')
|
||||||
}
|
}
|
||||||
if p.expected_type == enum_type.name {
|
if p.expected_type == enum_type.name {
|
||||||
p.warn('`${enum_type.name}.$val` is unnecessary, use `.$val`')
|
// `if color == .red` is enough
|
||||||
|
// no need in `if color == Color.red`
|
||||||
|
p.error('`${enum_type.name}.$val` is unnecessary, use `.$val`')
|
||||||
}
|
}
|
||||||
|
|
||||||
// println('enum val $val')
|
// println('enum val $val')
|
||||||
p.gen(mod_gen_name(enum_type.mod) + '__' + enum_type.name + '_' + val)// `color = main__Color_green`
|
p.gen(mod_gen_name(enum_type.mod) + '__' + enum_type.name + '_' + val)// `color = main__Color_green`
|
||||||
p.next()
|
p.next()
|
||||||
|
Loading…
Reference in New Issue
Block a user