-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix #3125: Added documentation for printf in the MemoryIO class #3126
Fix #3125: Added documentation for printf in the MemoryIO class #3126
Conversation
It probably should list the available specifiers, the implementation is at https://github.com/crystal-lang/crystal/blob/master/src/string/formatter.cr |
@jhass Okay. I'll write the available specifiers. Should I also write about the error thrown in case the number of arguments are less than the number of specifiers |
Yes, sure, sounds good. |
… arguments to the documentation of printf in MemoryIO class
# %i => decimal | ||
# %x => hexadecimal | ||
# %X => hexadecimal | ||
# %a, %A, %e, %E, %f, %g, %G => char |
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.
I think mentioning the possible input types and giving an example would be good. Also mentioning %{foo}
and %<foo>d
. Finally the flags and modifiers for those that take it.
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.
@jhass What is the representation of the value called after it is formatted by %a
or %A
. I got these results while trying out.
io = MemoryIO.new
io.printf("Hello %a", 4)
p io.to_s # => "Hello 0x1p+2"
What is this form 0x1p+2
called?
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.
I strongly suggest to base the docs on this: http://ruby-doc.org/core-2.2.0/Kernel.html#method-i-sprintf
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.
There are some differences, but Ruby docs on this are pretty good
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.
Cool. I shall try to follow the Ruby docs.
Adding the documentation for printf in the MemoryIO class to fix this issue