Friday 15 May 2015

Ruby: changing the appearances strings without changing their original values -



Ruby: changing the appearances strings without changing their original values -

i'm trying create spider solitaire ruby. want show first element in array on screen. example...

a = ["ah", "1h", "2h", "3h", "4h", "5h"]

this array represents pile of cards ace 5 in suits of heart. programme print on screen...

a = ["ah", "card", "card", "card", "card", "card"]

but still want a[1] homecoming "1h", not "card". there way alter appearances of strings without changing original values?.

puts a.map.with_index{|e, i| i.zero? ? e : "card"}

ruby

No comments:

Post a Comment