挣扎着这个简单的任务。不是Ruby的专家:
def self.send_mass_sms(*number, message)
*number.each do |n|
@client.messages.create(
from: ENV['TWILIO_PHONE_NUMBER'],
to: "+370#{n}",
body: "#{message}"
)
end
end
号码为string[]
- [" 657765"," 765475"]
错误:
语法错误,意外' \ n',期待&amp ;.或::或' ['或者'。'
答案 0 :(得分:3)
尝试删除*
符号
def self.send_mass_sms(*number, message)
number.each do |n|
@client.messages.create(
from: ENV['TWILIO_PHONE_NUMBER'],
to: "+370#{n}",
body: "#{message}"
)
end
end