ziglings/exercises/079_quoted_identifiers.zig

31 lines
882 B
Zig
Raw Normal View History

2021-05-09 13:10:09 -04:00
//
// Sometimes you need to create an identifier that will not, for
// whatever reason, play by the naming rules:
//
// const 55_cows: i32 = 55; // ILLEGAL: starts with a number
// const isn't true: bool = false; // ILLEGAL: what even?!
//
// If you try to create either of these under normal
// circumstances, a special Program Identifier Syntax Security
// Team (PISST) will come to your house and take you away.
//
// Thankfully, Zig has a way to sneak these wacky identifiers
// past the authorities: the @"" identifier quoting syntax.
//
// @"foo"
2021-11-05 11:44:29 -04:00
//
2021-05-09 13:10:09 -04:00
// Please help us safely smuggle these fugitive identifiers into
// our program:
//
const print = @import("std").debug.print;
pub fn main() void {
2024-06-12 06:54:01 -04:00
const @"55_cows": i32 = 55;
const @"isn't true": bool = false;
2022-05-18 15:39:36 -04:00
2021-05-09 13:10:09 -04:00
print("Sweet freedom: {}, {}.\n", .{
2024-06-12 06:54:01 -04:00
@"55_cows",
@"isn't true",
2021-05-09 13:10:09 -04:00
});
}