Newer
Older
2024-Tsubasa / system / websocket_test / em-ws-web(intro) / test / array.rb
@tsubasa tsubasa on 30 Jul 2024 753 bytes add: websocket dir
#!/usr/bin/env ruby

#make for array
button_clicker = []

def hayaoshi(button_clicker, team, name)
  flag = false
  button_clicker.each do |key, value|
    if key == team
      flag = true
    end
  end
  if flag == false
    button_clicker.push([team, name])
    return printf("%s の %s さん!\n", team, name)
  end
end

str = hayaoshi(button_clicker, "team2", "tsubasa")
puts str
# hayaoshi(button_clicker, "team2", "tubasa")
# hayaoshi(button_clicker, "team1", "wow")

# p button_clicker
# button_clicker.each do |key, value|
#   printf("%s の %s さん!\n", key, value)
# end


# str = "team2 の tsubasa がボタンを押しました"
# str.match(/(team\d)\sの\s([0-9a-z]+)\s/)
# team = $1
# name = $2
# puts "team = #{team}, name = #{name}"