-2

Struggling with this simple task. Not an expert at 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

number is string[] - ["657765", "765475"]

Error:

syntax error, unexpected '\n', expecting &. or :: or '[' or '.'

  • "**Struggling** with this **simple** task."---looks self-contradictory. – sawa Oct 30 '17 at 17:17
  • 1
    Try to understand when to use `*numbers` and `numbers`. Follow the link - https://stackoverflow.com/a/918479/787980 – Pramod Solanky Oct 30 '17 at 17:30
  • @sawa - self-contradictory is also when people comes here to help, but doesn't do that.. –  Oct 30 '17 at 19:17

1 Answers1

3

Try removing * sign

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
Nimish Gupta
  • 3,095
  • 1
  • 12
  • 20