mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-11-09 19:40:48 -05:00
Removed incorrect explanation of assignment error (#1)
It really has nothing to do with the if/else expression. The peer types are being resolved correctly. The same error can be produced with something as simple as: var foo = 5;
This commit is contained in:
parent
961cf22b88
commit
5b47e8ebe6
2 changed files with 5 additions and 8 deletions
|
@ -3,14 +3,6 @@
|
||||||
//
|
//
|
||||||
// var foo: u8 = if (a) 2 else 3;
|
// var foo: u8 = if (a) 2 else 3;
|
||||||
//
|
//
|
||||||
// Note: You'll need to declare a variable type when assigning a value
|
|
||||||
// from a statement like this because the compiler isn't smart enough
|
|
||||||
// to infer the type for you.
|
|
||||||
//
|
|
||||||
// This WON'T work:
|
|
||||||
//
|
|
||||||
// var foo = if (a) 2 else 3; // error!
|
|
||||||
//
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
|
|
5
ziglings
5
ziglings
|
@ -116,6 +116,11 @@ check_it 41_pointers3.zig "foo=6, bar=11"
|
||||||
check_it 42_pointers4.zig "num: 5, more_nums: 1 1 5 1"
|
check_it 42_pointers4.zig "num: 5, more_nums: 1 1 5 1"
|
||||||
check_it 43_pointers5.zig "Wizard (G:10 H:100 XP:20)"
|
check_it 43_pointers5.zig "Wizard (G:10 H:100 XP:20)"
|
||||||
check_it 44_quiz5.zig "Elephant A. Elephant B. Elephant C." "Oh no! We forgot Elephant B!"
|
check_it 44_quiz5.zig "Elephant A. Elephant B. Elephant C." "Oh no! We forgot Elephant B!"
|
||||||
|
# optional vals (simple scalar)
|
||||||
|
# optional fields (elephant tail - no longer need circular)
|
||||||
|
# super-simple struct method
|
||||||
|
# use struct method for elephant tails
|
||||||
|
# quiz: add elephant trunk (like tail)!
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo " __ __ _ "
|
echo " __ __ _ "
|
||||||
|
|
Loading…
Reference in a new issue