diff options
| author | Chris Boesch <[email protected]> | 2023-03-30 23:22:09 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-30 23:22:09 +0200 |
| commit | 5469a7b89f8d899b05470afd2b4241c4811e5428 (patch) | |
| tree | 643ba4c7d88cbc9904c49962b99e4673ab5f0b9f | |
| parent | aa01f6eea94e40e7e24e7ef20d109139acf0c7d1 (diff) | |
| parent | b16cd86906ad56d945243bbc335d74cf6041425f (diff) | |
| download | ziglings-5469a7b89f8d899b05470afd2b4241c4811e5428.tar.xz ziglings-5469a7b89f8d899b05470afd2b4241c4811e5428.zip | |
Merge pull request #208 from chrboesch/issue_140
function made more elegant
| -rw-r--r-- | exercises/048_methods2.zig | 9 | ||||
| -rw-r--r-- | patches/patches/048_methods2.patch | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/exercises/048_methods2.zig b/exercises/048_methods2.zig index 310867a..3291965 100644 --- a/exercises/048_methods2.zig +++ b/exercises/048_methods2.zig @@ -52,12 +52,9 @@ fn visitElephants(first_elephant: *Elephant) void { e.print(); e.visit(); - // This gets the next elephant or stops. - if (e.hasTail()) { - e = e.???; // Which method do we want here? - } else { - break; - } + // This gets the next elephant or stops: + // which method do we want here? + e = if (e.hasTail()) e.??? else break; } } diff --git a/patches/patches/048_methods2.patch b/patches/patches/048_methods2.patch index 781a99e..cd1b5d0 100644 --- a/patches/patches/048_methods2.patch +++ b/patches/patches/048_methods2.patch @@ -1,4 +1,4 @@ 57c57 -< e = e.???; // Which method do we want here? +< e = if (e.hasTail()) e.??? else break; --- -> e = e.getTail(); // Which method do we want here? +> e = if (e.hasTail()) e.getTail() else break; |
