Skip to content

Instantly share code, notes, and snippets.

@fractalatcarf
Created March 31, 2017 08:34
Show Gist options
  • Save fractalatcarf/eb5c241522e15e829ad03c3b57ba4e85 to your computer and use it in GitHub Desktop.
Save fractalatcarf/eb5c241522e15e829ad03c3b57ba4e85 to your computer and use it in GitHub Desktop.
live code du matin
# # # students_names = ["Pierre", "Claire", "Edouard", "Monique"]
# # # students_ages = ["45", "29", "32", "89"]
# # # students_names.each_with_index do |name, i|
# # # puts "#{name} a #{students_ages[i]} ans"
# # # end
# # # students_ages["Pierre"]
# # students_ages = {
# # "Pierre" => 45,
# # "Claire" => 29,
# # "Edouard" => { "age" => 29, "Taille" => 145},
# # "Monique" => "89"
# # }
# # puts students_ages["Edouard"]["age"]
# # students_ages["Edouard"]["age"] = 65
# # p students_ages.has_key?("Guillaume")
# # p students_ages.include?("Claire")
# # p students_ages
# # students_ages["Guillaume"] = 28
# # # students_ages.delete("Pierre")
# # # p students_ages
# # # p students_ages.keys
# # # students_ages.delete_at(3)
# # # p students_ages
# # students_ages.each_with_index do |item, i|
# # puts "#{item} (#{i})"
# # end
# paris = {
# footbal_team: "PSG",
# country: "France",
# population: 2211000
# }
# london = {
# :country => "England",
# :population => 8308000,
# footbal_team: "Arsenal"
# }
# p paris[:country]
# paris[:footbal_team] = "PSG"
# p paris
# p paris.keys
# p london.keys
def tag(tag, content, attributes)
attr = ""
attributes.each do |name, value|
attr += "#{name}=\"#{value}\" "
end
puts "<#{tag} #{attr}>#{content}</#{tag}>"
end
puts tag "h1", "Hello", class: "super", href: "toto.com", src: "titi"
# method titi: "toto", name: "Edouard"
# <h1 class="super">Hello</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment