-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加 IfThenElse
函数返回泛型结果
#259
Merged
Merged
Conversation
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
我会觉得说,可能需要的是一个类似三木操作符的东西,解决我长期以来的一个困扰: 然后还要考虑获得返回值的问题 |
或者提供两个方法: 一个是用来计算值,一个是用来执行动作 |
flycash
reviewed
Nov 2, 2024
flycash
reviewed
Nov 2, 2024
bigdavidwong
force-pushed
the
feature/if_then_else
branch
from
November 2, 2024 14:29
cc354bb
to
16e4422
Compare
@flycash 已按照建议进行了修改,请帮忙重新审查,谢谢~ |
flycash
reviewed
Nov 7, 2024
flycash
reviewed
Nov 7, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase 一下最新代码。
bigdavidwong
force-pushed
the
feature/if_then_else
branch
from
November 7, 2024 08:48
10e0547
to
317856e
Compare
非常感谢 |
flycash
pushed a commit
that referenced
this pull request
Nov 12, 2024
* update 1. 增加了一个条件判断返回泛型结果的函数; 1. 增加了一个条件判断执行对应方法的函数; 2. 调整和增加单元测试和Example; * IfThenElseFunc固定增加错误返回,泛型T作为用户可以自定义返回的结果 --------- Co-authored-by: huangdawei <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
添加 IfThenElse 函数
此 PR 添加了一个
IfThenElse
函数,它根据条件返回对应的泛型结果。该函数允许在单行代码中实现类似三元运算符的功能。功能概述:
IfThenElse[T any](condition bool, trueValue, falseValue T) T
根据布尔条件返回trueValue
或falseValue
。trueValue
和falseValue
在传入时即会访问,因此调用方需确保它们的合法性。示例: