Created
June 5, 2019 11:11
-
-
Save swarnimarun/53d1f67e53b000ca069b30f1772aadd3 to your computer and use it in GitHub Desktop.
Yield GDScript Simple quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node | |
func my_looper(): | |
for x in 4: | |
yield() | |
print("I am %sx awesome" % x) | |
func _ready(): | |
var v = my_looper() | |
# Question 1: HOW WILL WE CALL ALL THE SUBROUTINES ? | |
# OPTION 1! | |
# v.resume() | |
# v.resume() | |
# v.resume() ... until all the FunctionState is empty | |
# OPTION 2! | |
# v.resume().resume() ... for every FunctionState returned | |
# OPTION 3! | |
# v.resume() .. doing it once is enough | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node | |
func my_looper(): | |
for x in 4: | |
yield() | |
print("I am %sx awesome" % x) | |
func _ready(): | |
var v = my_looper() | |
v.resume().resume().resume().resume() # 4 times for all the executions combined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment