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

feature: multiple-values and separator #75

Merged
merged 3 commits into from
Mar 15, 2020

Conversation

YusukeHosonuma
Copy link
Owner

@YusukeHosonuma YusukeHosonuma commented Mar 15, 2020

Support multiple-values to output like print of standard library.

Example

print("Hello", 42)
// => "Hello" 42

Debug.print("Hello", 42)
// =>  "Hello" 42

Debug.print("Hello", 42, separator: ", ") // use custom `separator`
// =>  "Hello", 42

Debug.prettyPrint(["Hello", "World"], 42)
// =>
// [
//     "Hello",
//     "World"
// ]
// 42

Limitation

Operator based API such as Debug.p >>> is not supported multiple values. Because operator must have one or two arguments, this is limitation of Swift.

image

Related

#76

@codecov-io
Copy link

codecov-io commented Mar 15, 2020

Codecov Report

Merging #75 into master will increase coverage by 0.61%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #75      +/-   ##
==========================================
+ Coverage   74.84%   75.46%   +0.61%     
==========================================
  Files           8        8              
  Lines         318      326       +8     
==========================================
+ Hits          238      246       +8     
  Misses         80       80              
Impacted Files Coverage Δ
Sources/API/Debug.swift 71.11% <80.00%> (+6.24%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf83e00...ee1ef33. Read the comment docs.

@@ -19,119 +19,147 @@ public class Debug {
// MARK: Standard API

extension Debug {
/// Output `target` to console.
/// Output `targets` to console.
Copy link
Owner Author

Choose a reason for hiding this comment

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

s/target/targets/g

public static func print(
_ target: Any
_ targets: Any...,
separator: String = " "
Copy link
Owner Author

Choose a reason for hiding this comment

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

This default value " " is similar to standard library.
https://developer.apple.com/documentation/swift/1541053-print

}

// MARK: - private

private static func _print(
_ target: Any
_ targets: [Any],
Copy link
Owner Author

Choose a reason for hiding this comment

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

Can't use targets: Any... because targets are passed to one array of argument instead of multiple values called from print() in this source.

Copy link
Collaborator

@sahara-ooga sahara-ooga Mar 15, 2020

Choose a reason for hiding this comment

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

That is due to Swift language design😎

@YusukeHosonuma YusukeHosonuma marked this pull request as ready for review March 15, 2020 03:50
@YusukeHosonuma YusukeHosonuma changed the title feature: multiple-values to output feature: multiple-values and separator Mar 15, 2020
Copy link
Collaborator

@sahara-ooga sahara-ooga left a comment

Choose a reason for hiding this comment

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

OK!

@YusukeHosonuma YusukeHosonuma merged commit 664a2bf into master Mar 15, 2020
@YusukeHosonuma YusukeHosonuma deleted the feature/multiple-values branch March 15, 2020 05:16
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

3 participants