Skip to content
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

Welcome: operator-based API #65

Merged
merged 5 commits into from
Mar 8, 2020
Merged

Conversation

YusukeHosonuma
Copy link
Owner

@YusukeHosonuma YusukeHosonuma commented Mar 6, 2020

What the customer needed :)

Debug.p >>> 42
// => 42

Debug.p >>> 42 + 1 // It can also be applied to expression
// => 43

Debug.p >>> String(string.reversed()).hasSuffix("eH")
// => true

Debug.pp >>> ["Hello", "World"]
// =>
// [
//     "Hello",
//     "World"
// ]

Reference

https://developer.apple.com/documentation/swift/swift_standard_library/operator_declarations

}

@discardableResult
public func >> (_: Debug.P, target: Any) -> String {
Copy link
Owner Author

@YusukeHosonuma YusukeHosonuma Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chosen >> because looks are intuitively like starlight for programmers, and less likely to conflict.

I decided use the custom operator >>> in finally.

Because the operator >> has higher precedence than all standard operators, therefore can't apply to any expressions.

@YusukeHosonuma YusukeHosonuma force-pushed the feature/operator-syntax branch 2 times, most recently from 0e94589 to 64bd639 Compare March 6, 2020 01:51
}

precedencegroup PrintPrecedence {
lowerThan: FunctionArrowPrecedence
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@po-miyasaka po-miyasaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙆‍♂️great!🙆‍♀️

@YusukeHosonuma YusukeHosonuma merged commit 3d91889 into master Mar 8, 2020
@YusukeHosonuma YusukeHosonuma deleted the feature/operator-syntax branch March 8, 2020 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants