mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-13 01:21:38 -07:00
Procedure Literal
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
import "test"
|
||||
|
||||
add :: proc(a, b: int) -> int {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
+18
-2
@@ -1,11 +1,27 @@
|
||||
import "other"
|
||||
// import "other"
|
||||
|
||||
TAU :: 6.28;
|
||||
PI :: PI/2;
|
||||
|
||||
type AddProc: proc(a, b: int) -> int;
|
||||
|
||||
|
||||
do_thing :: proc(p: AddProc) {
|
||||
p(1, 2);
|
||||
}
|
||||
|
||||
add :: proc(a, b: int) -> int {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
|
||||
main :: proc() {
|
||||
x : int = 2;
|
||||
x = x * 3;
|
||||
|
||||
y := add(1, x);
|
||||
// do_thing(add(1, x));
|
||||
do_thing(proc(a, b: int) -> f32 {
|
||||
return a*b - a%b;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user