-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
docs: fix example for sort
and add new doctest
#56843
Conversation
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.
Maybe we can make the comment into doctest as well.
julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs))
4-element Vector{Int64}:
2
1
3
0
julia> ans == sort(0:3, by=x->abs(x-2))
true
Or
julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs))
4-element Vector{Int64}:
2
1
3
0
julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs)) == sort(0:3, by=x->abs(x-2))
true
Looks good - would be great to get the other doctest in also as suggested. |
never created a doctest before, I'll try to look into it in a few hours, all pointers and hints/tips welcome |
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.
Agreed it would be nice to have the version in comment tested by the doctest.
@rapus95 the whole Markdown code block in this comment, with all these examples, is one big doctest. It should just be a matter of replacing a part of the code block with another, exactly as proposed by @inkydragon . Then to test the doctest locally you can compile Julia and run the test command as described in CONTRIBUTING.md.
I added the 2nd proposal (which doesn't use |
sort!
docssort
and add new doctest
No description provided.