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

Standalone ternary operations don't work despite manual claiming otherwise #2682

Closed
1 of 2 tasks
jarrrodnb opened this issue Jan 8, 2024 · 1 comment
Closed
1 of 2 tasks
Assignees
Labels
docs-bug GameMaker Manual Bugs

Comments

@jarrrodnb
Copy link

Description

On the gml manual page 'if / else and Conditional Operators', the example shows a ternary operation being used without being part of a variable assignment.

The specific example is the third line of code here:
image

That line implies that it's possible to use ternary operators for standalone 'if-else' shortcuts (as is standard for many languages).

However when copy/pasting that line in, or trying any other variation, for example:
(instance_exists(obj)) ? instance_destroy() : instance_create_depth(x, y, 0, obj);

You are just met with this feather error GM1007 Left-hand side of an assignment must be a variable., which prevents compiling the game.

Expected Change

No response

Steps To Reproduce

Copy & paste in the code from the manual: (--hp <= 0) ? instance_destroy() : score += 10; into a project.

Gamemaker will then prevent compiling.

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

2023.11.1 (Monthly)

Which operating system(s) are you seeing the problem on?

Windows 10

Are you running GameMaker from inside your Steam library?

None

Contact Us Package Attached?

  • I have attached my Contact Us Package

Sample Project Added?

  • I have included a small sample project
@jarrrodnb jarrrodnb added the ide-bug Bugs with the GameMaker IDE label Jan 8, 2024
@rwkay
Copy link

rwkay commented Jan 8, 2024

ternary operators cannot be used as statements they are part of an expression.

@stuckie stuckie added docs-bug GameMaker Manual Bugs and removed ide-bug Bugs with the GameMaker IDE labels Jan 9, 2024
YYBartT added a commit to YoYoGames/GameMaker-Manual that referenced this issue Jan 9, 2024
…ming otherwise

Closes YoYoGames/GameMaker-Bugs#2682
Kept the statement as an example on how the ternary operator cannot be used
@YYBartT YYBartT closed this as completed Jan 9, 2024
@YYBartT YYBartT self-assigned this Jan 9, 2024
gurpreetsinghmatharoo pushed a commit to YoYoGames/GameMaker-Manual that referenced this issue Aug 8, 2024
…ming otherwise

Closes YoYoGames/GameMaker-Bugs#2682
Kept the statement as an example on how the ternary operator cannot be used

(cherry picked from commit 9194590)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-bug GameMaker Manual Bugs
Projects
None yet
Development

No branches or pull requests

5 participants