-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Overhaul Array documentation #69451
Overhaul Array documentation #69451
Conversation
b5341b5
to
dd43f78
Compare
dd43f78
to
eed30c2
Compare
eed30c2
to
05247ab
Compare
05247ab
to
9a9a678
Compare
9a9a678
to
962143e
Compare
fbff5d4
to
e25de75
Compare
Under bsearch, can anyone write something to explain what this means:
The sense of it does not leap from the screen. What is an 'insertion index'? What is 'sorting order'? Why would a value not be in the array yet? 😄 |
Magic. I didn't know that trick. Thanks. Your description is very good! |
PS - There is some churn on the examples for |
I was there 😉 thank you for the reminder though! |
How's this for an example @AThousandShips @donn-xx ? func sort_by_amount(a, b):
if a[1] < b[1]:
return true
return false
func _ready():
var my_items = [["Tomato", 2], ["Kiwi", 5], ["Rice", 9]]
var apple = ["Apple", 5]
# "Apple" is inserted before "Kiwi".
my_items.insert(my_items.bsearch_custom(apple, sort_by_amount, true), apple)
var banana = ["Banana", 5]
# "Banana" is inserted after "Kiwi".
my_items.insert(my_items.bsearch_custom(banana, sort_by_amount, false), banana)
# Prints [["Tomato", 2], ["Apple", 5], ["Kiwi", 5], ["Banana", 5], ["Rice", 9]]
print(my_items) |
I think it looks good, not convinced it's needed though, but I'd do: func sort_by_amount(a, b):
return a[1] < b[1] |
I chose to be explicit as some users do not "wrap around the idea" of comparisons returning Also yeah, it's needed (less in this PR because it's better explained). It's not readily apparent and it combines well with |
Ah, I see. You pass an array to bsearch_custom. I think the answer is to make it clear that both |
That's not the case, you can search for anything as long as you handle it correctly In fact I think the one context where it would be good to add an example is to handle that detail, like searching for |
403833c
to
5bbc31d
Compare
For the love of the almighty this PR is so old the screenshot taken as a preview doesn't even match how the built-in documentation looks like anymore. I have expanded upon |
True. I was speaking about practical use. Yeah, I didn't think about probing the argument types within the func and then changing behaviour dynamically.
Indeed! This would help. |
5bbc31d
to
a379080
Compare
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 spent the better part of an hour poring over the changes. There are some small parts I could quibble about, but with a change this size, that is always going to be the case. None IMO are important enough to block this further, seeing how long it has been open.
What matters is that overall, this is a large improvement IMO, and none of the few things above matter too much. Overall, this is more clear, more carefully worded and links relevant info. My take is to get this in. :)
a379080
to
479e5ef
Compare
479e5ef
to
31a9c63
Compare
Thanks! Impressive work as usual 🎉 |
I have been freed from the curse. |
Closes godotengine/godot-docs#6964
Closes godotengine/godot-docs#8695
Closes godotengine/godot-docs#9005
Closes #79066
Closes #89276 (properly)
Closes godotengine/godot-docs#9067
Continuation of a series of PRs that go on to touch major, yet majorly unrevised class references. This includes #67072, #67100, #67208, #67718,... #67880 and #68560... and #68649... And I think I'll end up putting all of these in a more organised list at some point.
General
[param]
and several other strong references more often;# Prints "5"
-># Prints 5
);print()
;+
operator" thing out of the leading description.Constructors
Array(from)
Methods
bsearch
,bsearch_custom
bsearch
example;all
,any
,map
,reduce
negate
->double
)clear
contains
7
is not equal to7.0
).duplicate
erase
,remove_at
,insert
,pop_at
,pop_front
Patronising...
fill
find
,rfind
hash
is_typed
set_typed
[br]
).*
shuffle
randomize
to ensure that a new seed will be used each time if you want non-reproducible shuffling."In Godot 4, the seed is randomly generated once at start-up, so this is no longer necessary, but the "opposite" is.
*
slice
###
sort
sort_custom
Modified example to use nested Dictionaries over nested Arrays, to potentially be less confusing while keeping it brief.sort
description.Operators
+
+
,>
,>=
,<
,<=
[]
Feedback is very, very welcome.