intro-to-zig-talk/src/main-old.zig
2024-08-08 20:44:22 +02:00

44 lines
709 B
Zig

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});
}