Menu
CoddyTech

Output and Comments

Lesson 2 of 48 in Coddy's Ruby for GDScript Developers course.

GDScript uses indentation for blocks and a hash sign for comments; Ruby commonly closes blocks and definitions with end. A hash sign inside a quoted string remains data in both examples. Godot executes lifecycle callbacks, while Ruby runs top-level statements and uses require_relative for neighboring files. Ruby puts appends a newline and print does not. Keep task helpers separate from the locked input/output driver.

GDScript: complete program

extends SceneTree

func _init():
	var name = "Mira"
	# Preserve the space after the comma.
	print("Hello, " + name + "!")
	quit()

Ruby: complete program

print "oak!"
# A real comment
puts "#seed"
challenge icon

Challenge

Easy

Return two lines: the word Ticket and then the stripped input. Do not print inside the helper.

Return text from solve(input) without printing. The locked driver prints the returned text with one final newline and checks required public APIs independently.

Your code goes in exercise.rb. main.rb holds the supplied input/output code and cannot be edited.

Try it yourself

require_relative 'exercise'
def check(value)
  raise 'Public API check failed' unless value
end

STDOUT.write(solve(STDIN.read) + 10.chr)
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Ruby for GDScript Developers

Practice on your own: Online Ruby compiler