v
v copied to clipboard
multi value variable
A simple and easy way to handle multiple variables as a set of variables.
For example, use keywords such as record
to allocate variables of multiple types as a single variable.
here's how to use it.
fn investigate_1(){
mut rows := []record{
no int
f1 int
f2 f64
calc1 f64
calc2 f64
}
for ....{
rows << .....
}
top := rows.sort()[0].calc1
}
Currently, structures cannot be declared within functions. Since we simply want to treat multiple variables as a single variable, we do not need advanced functionality such as structs. This is a simplified version of the structure.
It looks like sumtype
Looks like structures or union or maybe array.
fn foo(....) (int, int){
....
}
fn main(){
mut rows := []record{
id int
sum int
}
for d in data{
rows << foo(d.col1, ....)
}
.....
}
For example, it would be very useful to be able to add directly from multi-value like this.
Oh, i see.