+2 votes

Just a simple question for one concerned with memory. Does it matter in either case which I choose to check if a value is between two numbers?

in Engine by (57 points)

1 Answer

+3 votes

Assuming if x in range(y,z) works the way i expect it to work I believe the latter will be more efficient, as for you to possibly check if an item is in an array you have to loop through it(assuming the program doesn't recognize that the array is defined easily with a mathematical function), so checking for bounds is better as if x >= y and x < z rather than if x in range(y,z)

by (1,204 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.