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

Clarify description on ds_map_add() to make the difference between the function and the $ accessor clear when overwriting existing keys #4795

Closed
Grisgram opened this issue Feb 23, 2024 — with GM Bug Reporter · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation are required by this issue

Comments

@Grisgram
Copy link

Grisgram commented Feb 23, 2024

Description

Hey there,

The manual for ds_map_add contains confusing text, which forced me to try out, what really happens.
Would be great, if you could state the difference between ds_map_add and access through accessor clearly.

Manual says, ds_map_add can return false, if the key exists. This is correct.
Then you show this code examples:

ds_map_add(map, 5, undefined);
ds_map_add(map, "level", 1);
ds_map_add(map, 89.6, "hello world");
ds_map_add(map, 5, buffer_get_address(buff));

but you mention with no word, that the last line will fail and the function will return false here.

IN ADDITION to that, you added a part for the accessors, when they were released, with almost the same samples,

map[? 5] = undefined;
map[? "level"] = 1;
map[? 89.6] = "hello world";
map[? 5] = buffer_get_address(buff);

And again, you mention not with a single word, that in this case the last line will succeed!

This is mega-confusing.

I wrote these few testing lines to prove:

test = ds_map_create();
test[? "hallo"] = "welt";
test[? "hallo"] = "world";
show_debug_message($"--- {test[?"hallo"]}");vlog
ds_map_destroy(test);

test = ds_map_create();
ds_map_add(test, "hallo", "welt");
ds_map_add(test, "hallo", "world");
show_debug_message($"--- {test[?"hallo"]}");
ds_map_destroy(test);

And indeed, the first block prints

--- world

to the log and the second block prints

--- welt

as this block uses ds_map_add instead of the accessors.

You need to make this clear in the manual!

thanks for reading,
kind regards
Gris

Steps To Reproduce

  • run the code shown above and adapt the manual accordingly

0bd05f22-3783-4e2e-9c0a-879a3d8a9445

@gm-bug-reporter gm-bug-reporter bot added the documentation Improvements or additions to documentation are required by this issue label Feb 23, 2024
@gurpreetsinghmatharoo gurpreetsinghmatharoo changed the title Manual-Error (or confusing text) in ds_map_add Clarify description on ds_map_add() to make the difference between the function and the $ accessor clear when overwriting existing keys May 7, 2024
gurpreetsinghmatharoo added a commit to YoYoGames/GameMaker-Manual that referenced this issue May 7, 2024
…ence between the function and the $ accessor clear when overwriting existing keys

YoYoGames/GameMaker-Bugs#4795
@github-project-automation github-project-automation bot moved this from Backlog to Done in Team Workload May 7, 2024
@gurpreetsinghmatharoo gurpreetsinghmatharoo moved this from Done to Ready for QA in Team Workload May 7, 2024
gurpreetsinghmatharoo added a commit to YoYoGames/GameMaker-Manual that referenced this issue Aug 8, 2024
…ence between the function and the $ accessor clear when overwriting existing keys

YoYoGames/GameMaker-Bugs#4795

(cherry picked from commit c9eb354)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation are required by this issue
Projects
Status: Ready for QA
Development

No branches or pull requests

2 participants