AS
Size: a a a
AS
М
SR
def likes(names)
phrases = ["no one likes this", "likes this", "like this"]
if names.empty?
phrases[0]
elsif names.size == 1
"#{names[0]} #{phrases[1]}"
elsif names.size == 2
"#{names[0]} and #{names[1]} #{phrases[2]}"
elsif names.size == 3
"#{names[0]}, #{names[1]} and #{names[2]} #{phrases[2]}"
elsif names.size >= 3
"#{names[0]}, #{names[1]} and #{(names-names[0..1]).count} others #{phrases[2]}"
end
end
def likes(n,l='like this',s=n.size)
["no one likes this","%s likes this","%s and %s #{l}","%s, %s and %s #{l}","%s, %s and #{s-2} others #{l}"][s<4?s:-1]%[*n]
end
М
def likes(n,l='like this',s=n.size)
["no one likes this","%s likes this","%s and %s #{l}","%s, %s and %s #{l}","%s, %s and #{s-2} others #{l}"][s<4?s:-1]%[*n]
end
AS
М
М
М
М
SR
SR
М
SR
М
М
AS
М
М
SR
AS