Code Log

プログラミングの勉強メモを残していきます。

2040704 午前の勉強


<スポンサーリンク>

str1 = "string"
str2 = "string"

puts str1.object_id #19423512
puts str2.object_id #19423500

puts(str1 == str2) #true

puts "string".class #String

puts str1.length #6
str1 << "hoge"

puts str1.length #10

(1..100).each do |i|
  case i % 15
  when 0 then puts "FizzBuzz"
  when 3,6,9,12 then puts "Fizz"
  when 5,10 then puts "Buzz"
  else	puts i
  end
end

array = ["Bar","foo","hoeg"]

p array.map{|name| "G. #{name}"}

hash = {
	"sawada" => "yuka", "yoshida" => "katutoshi", "yamane" => "hisashi"
}

hash.each do |key, value|
	puts "#{value} #{key}"
end
require "tk"

TkLabel.new {
	text "hello world"
	bg "red"
	pack
}
TkButton.new {
	text "Close"
	command {exit}
	pack
}
Tk.mainloop