Menu
CoddyTech

Output and Comments

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

C# Console.WriteLine and Ruby puts both append a newline to ordinary text output. C# programs compile with an entry point, including one generated for top-level statements; Ruby executes top-level statements directly and loads neighboring files with require_relative. Keep declarations and reusable operations separate from the driver that owns input and output.

C#: complete program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
Console.WriteLine("Hi" + ", Ada");

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 C# Developers

Practice on your own: Online Ruby compiler