Skip to content

Example for conditionals #29

Description

@svenfuchs

The question what a more real-world example for an if statement with several branches could be came up, and the following was found:

color = :black

if color == :red
  puts "stop!"
elsif color == :yellow
  puts "stop!"
elsif color == :red_yellow
  puts "get ready"
elsif color == :green
  puts "go!"
else
  raise "AMPEL KAPUTT"
end

Also, unless doesn't seem to be mentioned?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions