Last active
April 18, 2020 07:02
-
-
Save bfloch/6fd416de0bc7a9b5a30f15e17c72708a to your computer and use it in GitHub Desktop.
error: cannot assign to constant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub const Data = struct { | |
count: u8, | |
pub fn init() Data { | |
return Data{ | |
.count = 0, | |
}; | |
} | |
pub fn append(self: Data, value: u8) !void { | |
if (self.count == 10) | |
return error.Overflow; | |
self.count += 1; | |
} | |
}; | |
pub fn main() !void { | |
var data = Data.init(); | |
try data.append(2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment