Variables and Data Types

Variables in Ruby are dynamically typed — you don’t need to declare the type explicitly. Ruby will infer it automatically.

Examples:

name = "Harshal"
age = 25
is_developer = true

Common Data Types:

  • String - Text (e.g., "Hello")
  • Integer - Whole numbers (e.g., 10)
  • Float - Decimal numbers (e.g., 3.14)
  • Boolean - true or false
  • Nil - Represents 'nothing'
← PrevNext →