Skip to content

Welcome to Tech by Example

Menu
  • Home
  • Posts
  • System Design Questions
Menu

Print/Output text in italic in Ruby Language

Posted on August 14, 2021August 14, 2021 by admin

Overview

ANSI escape codes can be used to output bold text in the console. Please note that

  • In MAC/Linux system terminal supports ANSI escape codes
  • Windows Command Prompt doesn’t support it. On windows, you can install Cygwin. ANSI escape codes work on that.

Program

class String
    def italic
        "\e[3m#{self}\e[23m"
     end
end

puts "Italic String".italic

Output

©2025 Welcome to Tech by Example | Design: Newspaperly WordPress Theme