#DOCUMENTATION by cg
authorClaus Gittinger <cg@exept.de>
Fri, 28 Jun 2019 12:47:17 +0200
changeset 24396 3dfb65acb1f0
parent 24395 c245e7c02c2d
child 24397 f8bd0c337564
#DOCUMENTATION by cg class: Magnitude comment/format in: #to:by:doWithBreak: changed: #to:by:doWithExit: category of: #to:by:doWithBreak:
Magnitude.st
--- a/Magnitude.st	Fri Jun 28 12:41:12 2019 +0200
+++ b/Magnitude.st	Fri Jun 28 12:47:17 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -253,8 +255,7 @@
 
     break := [^ self].
     tmp := self.
-"using #negative would be more portable, but stc does only inline #< but not #negative (yet)"
-"/    incr negative ifTrue:[
+    "using #negative would be more portable, but stc does only inline #< but not #negative (yet)"
     incr < 0 ifTrue:[
         [tmp < stop] whileFalse:[
             aBlock value:tmp value:break.
@@ -267,7 +268,6 @@
         ]
     ]
 
-
     "
      1 to:100 by:5 doWithBreak:[:index :break |
         Transcript showCR:index printString.
@@ -276,19 +276,24 @@
         ].
      ]
     "
+
+    "Modified (comment): / 28-06-2019 / 12:44:35 / Claus Gittinger"
 !
 
 to:stop by:incr doWithExit:aBlock
     "For each element of the interval from the receiver up to the argument stop, incrementing
      by step, evaluate aBlock passing the element as argument.
-     Pass a break argument, to allow for premature exit of the loop."
+     Pass a break argument, to allow for premature exit of the loop.
+     Returns nil or the value passed to the exit>>value: message.
+
+     Notice, that this is different to a return statement in the block, 
+     which returns from the enclosed method, NOT only from the block."
 
     |tmp exit|
 
     exit := [:exitValue | ^ exitValue].
     tmp := self.
-"using #negative would be more portable, but stc does only inline #< but not #negative (yet)"
-"/    incr negative ifTrue:[
+    "/    incr negative ifTrue:[
     incr < 0 ifTrue:[
         [tmp < stop] whileFalse:[
             aBlock value:tmp value:exit.
@@ -299,7 +304,8 @@
             aBlock value:tmp value:exit.
             tmp := tmp+incr
         ]
-    ]
+    ].
+    ^ nil
 
     "
      1 to:100 by:5 doWithExit:[:index :exit |
@@ -309,6 +315,8 @@
         ].
      ]
     "
+
+    "Modified: / 28-06-2019 / 12:46:35 / Claus Gittinger"
 !
 
 to:stop count:aBlock