News for hackers. Stuff that matters.
Re:Principle of Least Astonishment by jolmg on Monday April 06, 2020 @04:40PM (#22797607)
My pet-peeve in ruby:

  '//'.split('/') # => [] instead of ['', '', '']
  '/'.split('/') # => [] instead of ['', '']
  ''.split('/') # => [] instead of ['']

  '//'.split('/', -1) # => ['', '', '']
  '/'.split('/', -1) # => ['', '']
  ''.split('/', -1) # => [] instead of ['']
In comparison:

  "".split("/") # => [""] in javascript
  "".split("/") # => [""] in python
Re:Principle of Least Astonishment by drewcoo on Monday April 06, 2020 @05:46PM (#22798214)
But if "instead of" means "I expected," doesn't that also mean that Javascript and Python don't do what you expected?
Re:Principle of Least Astonishment by ithkuil on Monday April 06, 2020 @06:15PM (#22798422)
JS & python both have:

'//'.split('/') => [ '', '', '' ] '/'.split('/') => [ '', '' ] '',split('/') => [ '' ]

so they indeed produce what parent expected.