0

I am looking at some ruby code. But am unsure what is happening on this line:

n,1 = gets.split.map &:to_i

I understand some input array of strings is being mapped to an array of integers but why is that being assigned to n,1?

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653
  • 1
    Does it run? in std. IRB it doesn't. Where does it come from? – Roger Mar 16 '15 at 22:59
  • 1
    Are you sure, there is a `1` (one), not an `l` (el)? Otherwise, which Ruby are you running? – undur_gongor Mar 16 '15 at 23:00
  • Thanks for pointing that out it was an L not a 1 –  Mar 16 '15 at 23:27
  • There was an edit to the question that completely changed it in such a way that existing answers are no longer valid. Doing such a thing is generally considered rude, since it means that the effort that was put in the existing answers was in vein. It also means that the existing answers will be unfairly downvoted for not answering the question. Thus, I rolled back the edit. – Jörg W Mittag Mar 16 '15 at 23:30
  • Cool makes sense. I'll ask it again with an 'l' –  Mar 16 '15 at 23:31

1 Answers1

1

That line of code doesn't do anything, it's simply a SyntaxError. You can't assign to 1, that's not a legal name for a local variable.

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653