forresty
7/5/2017 - 2:41 AM

boolean.rb

forrest_is_handsome && forrest_is_tall # => false
forrest_is_handsome || forrest_is_tall # => true
# puts "Which action? [read|write|exit]"
# action = gets.chomp

# case action
# when "read"
#   puts 'You are in READ mode'
# when "write"
#   puts 'You are in WRITE mode'
# when "exit"
#   puts 'Bye Bye'
# when "read"
#   puts 'You are in READ mode AGAINNNNNN!'
# else
#   puts 'Wrong action'
# end


Fixnum === object

object = 123

case object
when Fixnum
  puts "it is int"
when String
  puts "it is string"
end
sides = %w{ head tail }

coin = sides.sample

print "guess? > "

guess = gets.chomp

result = (guess == coin ? "win" : "lose")
# result = if guess == coin
#   'win'
# else
#   'lose'
# end

# if guess == coin
#   result = 'win'
# else
#   result = 'lose'
# end


puts result
# for i in [1,2,3]
#   puts i
# end

# for i in (0..5)
#   puts i
# end


# [1,2,3].each do |i|
#   puts i
# end

(1..5).each do |i|
  puts i
end

# CRUD
#
# Create
# Retrieve
# Update
# Delete
# num = 1 + rand(5)

# print "your guess? > "
# guess = gets.chomp.to_i

# until num == guess
#   puts "try agains!"

#   print "your guess? > "
#   guess = gets.chomp.to_i
# end

# puts "you got it!"

num = 1 + rand(5)

# while true

loop do
  print "your guess? > "
  guess = gets.chomp.to_i

  if num == guess
    puts "you got it!"
    # break
  else
    puts "try again!"
  end
end



# print "your guess? > "
# guess = gets.chomp.to_i

# if num == guess
#   puts "you got it!"
# else
#   puts "try agains!"
# end

def hello
  puts 'world'
  gjdosgjdosjgosgs
end

def gjdosgjdosjgosgs
  puts 'haha'
end

# hello
# hour = 23

# if hour < 12
#   puts "Good morning!"
# elsif hour >= 20
#   puts "Good night!"
# elsif hour > 12
#   puts "Good afternoon!"
# else
#   puts "Lunch time!"
# end


# def some_method(some_arg)
#   return nil if some_arg == nil


# end


# if !rainy
#   puts "go out!!!!!"
# else
#   puts "stay inside!"
# end
require_relative 'hello'

hello

if false
  puts 'haha'
end

puts "how old are you?"
# print "how old are you?\n"
print '> '

age = gets.chomp.to_i

if age >= 18
  puts "you can vote now in Taiwan!"
else
  puts "too young to vote.."
end


# array = [
#   [1,2],
#   [3,4]
# ]

# # puts array
# p array

# array = [1, 2, 3, nil]

# puts array
# p array
# puts nil
# p nil
# p array
# print array
# puts array.inspect