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

Improve documentation of String#% #6095

Merged
merged 2 commits into from
May 17, 2018
Merged

Improve documentation of String#% #6095

merged 2 commits into from
May 17, 2018

Conversation

wooster0
Copy link
Contributor

No description provided.

src/string.cr Outdated
# "Party like it's %d!!!" % 1999 # => "Party like it's 1999!!!"
# "I have %d apples" % 5 # => "I have 5 apples"
# "%s, %s, %s, D" % ['A', 'B', 'C'] # => "A, B, C, D"
# "sum: %{one} + %{two} = %{three}" % ({one: 1, two: 2, three: 1 + 2}) # => "sum: 1 + 2 = 3"
Copy link
Contributor

Choose a reason for hiding this comment

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

There is also "test%<x>s" % {x: 4} # => "test4"

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, what are those ()s doing there? They are totally not needed.

Copy link
Contributor Author

@wooster0 wooster0 May 14, 2018

Choose a reason for hiding this comment

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

Oh it looks like these parentheses got there for some reason when I compiled:

pp "sum: %{one} + %{two} = %{three}" % {one: 1, two: 2, three: 1 + 2}
"sum: %{one} + %{two} = %{three}" % ({one: 1, two: 2, three: 1 + 2}) # => "sum: 1 + 2 = 3"

Thats weird.

@sdogruyol sdogruyol merged commit 645afb0 into crystal-lang:master May 17, 2018
@sdogruyol sdogruyol added this to the Next milestone May 17, 2018
chris-huxtable pushed a commit to chris-huxtable/crystal that referenced this pull request Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants