mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-11-08 11:20:46 -05:00
Merge pull request #207 from chrboesch/i205
changed self paramter in waddle to pointer
This commit is contained in:
commit
aa01f6eea9
1 changed files with 4 additions and 4 deletions
|
@ -25,7 +25,7 @@ const Duck = struct {
|
|||
location_x: i32 = 0,
|
||||
location_y: i32 = 0,
|
||||
|
||||
fn waddle(self: Duck, x: i16, y: i16) void {
|
||||
fn waddle(self: *Duck, x: i16, y: i16) void {
|
||||
self.location_x += x;
|
||||
self.location_y += y;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ const RubberDuck = struct {
|
|||
location_x: i32 = 0,
|
||||
location_y: i32 = 0,
|
||||
|
||||
fn waddle(self: RubberDuck, x: i16, y: i16) void {
|
||||
fn waddle(self: *RubberDuck, x: i16, y: i16) void {
|
||||
self.location_x += x;
|
||||
self.location_y += y;
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ const DuctError = error{UnmatchedDiameters};
|
|||
|
||||
pub fn main() void {
|
||||
// This is a real duck!
|
||||
const ducky1 = Duck{
|
||||
var ducky1 = Duck{
|
||||
.eggs = 0,
|
||||
.loudness = 3,
|
||||
};
|
||||
|
||||
// This is not a real duck, but it has quack() and waddle()
|
||||
// abilities, so it's still a "duck".
|
||||
const ducky2 = RubberDuck{
|
||||
var ducky2 = RubberDuck{
|
||||
.in_bath = false,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue