Replies: 1 comment 3 replies
-
I have seen a lot of this kind of code in this project. switch (kind) {
.accent => ret = cs.accent orelse dvui.themeGet().style_content.accent,
.text => ret = cs.text orelse dvui.themeGet().style_content.text,
.fill => ret = cs.fill orelse dvui.themeGet().style_content.fill,
.border => ret = cs.border orelse dvui.themeGet().style_content.border,
.hover => ret = cs.hover orelse dvui.themeGet().style_content.hover,
.press => ret = cs.press orelse dvui.themeGet().style_content.press,
.press_text => ret = cs.press_text orelse dvui.themeGet().style_content.press_text,
} It can also be like this. This is shorter, but somehow less readable. switch (kind) {
inline else => |tag| {
ret = @field(cs, @tagName(tag)) orelse @field(dvui.themeGet().style_content, @tagName(tag));
},
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
(discussion about code style)
Beta Was this translation helpful? Give feedback.
All reactions