forked from nothke/intro-to-zig-talk
Initial
This commit is contained in:
43
src/main.zig
Normal file
43
src/main.zig
Normal file
@@ -0,0 +1,43 @@
|
||||
const std = @import("std");
|
||||
|
||||
fn calc(a: i32) i32 {
|
||||
return a;
|
||||
}
|
||||
|
||||
const SOmethin = enum {
|
||||
One,
|
||||
Two,
|
||||
Three,
|
||||
};
|
||||
|
||||
|
||||
fn Optional(comptime T: type) type {
|
||||
return struct {
|
||||
valid: bool,
|
||||
value: T,
|
||||
};
|
||||
}
|
||||
|
||||
fn add(a: anytype, b: anytype) @TypeOf(a + b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
const DivisionError = error{DivisionByZero};
|
||||
|
||||
fn divide(a: f32, b: f32) !f32 {
|
||||
if (b == 0)
|
||||
return DivisionError.DivisionByZero;
|
||||
|
||||
return a / b;
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
|
||||
|
||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
||||
|
||||
const vec = @Vector(4, i32){ 1, 0, 1, 0 };
|
||||
const vec2 = @Vector(4, i32){ 0, 1, 0, 1 };
|
||||
|
||||
std.debug.print("vec: {}", .{vec + vec2});
|
||||
}
|
Reference in New Issue
Block a user