SequenceableCollection.st
changeset 25286 25a8dda1990b
parent 25229 ffb4208adfe8
child 25344 b6b71d974e50
equal deleted inserted replaced
25285:4b23119f86e4 25286:25a8dda1990b
  3306      '1234567890' copyButFirst:2
  3306      '1234567890' copyButFirst:2
  3307      '12' copyButFirst:2
  3307      '12' copyButFirst:2
  3308      '' copyButFirst:2
  3308      '' copyButFirst:2
  3309 
  3309 
  3310      '' allButFirst:2
  3310      '' allButFirst:2
       
  3311     "
       
  3312 !
       
  3313 
       
  3314 copyButFirstAndLast
       
  3315     "return a new collection consisting of the receiver's elements
       
  3316      except for the first and last elements.
       
  3317      Raises an error if the receiver's size is less than 2."
       
  3318 
       
  3319     |sz|
       
  3320 
       
  3321     (sz := self size) < 2 ifTrue:[self notEnoughElementsError].
       
  3322     ^ self copyFrom:2 to:(sz - 1)
       
  3323 
       
  3324     "
       
  3325      #($a $b $c $d $e $f $g) copyButFirstAndLast
       
  3326      '1234567890' copyButFirstAndLast
       
  3327      '1' copyButFirstAndLast
       
  3328      '' copyButFirstAndLast
       
  3329      'ab' copyButFirstAndLast
  3311     "
  3330     "
  3312 !
  3331 !
  3313 
  3332 
  3314 copyButLast
  3333 copyButLast
  3315     "return a new collection consisting of the receiver's elements
  3334     "return a new collection consisting of the receiver's elements