uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Range only for int #670

Closed JuanchiRios closed 8 years ago

JuanchiRios commented 8 years ago

Wollok only supports range for integer values? class Range extends AbstractJavaWrapper<IntegerRange>

If i do

var rango =new Range(5,10)
rango.map({x=>x*2}).toString()

i get [10, 12, 14, 16, 18, 20]

but if i do

var rango = new Range(5.0,10.0)
rango.map({x=>x*2.0}).toString()

i get wollok.lang.Exception: java.math.BigDecimal cannot be cast to java.lang.Integer at wollok.lang.Range.forEach(closure) [/wollok.wlk:602] at wollok.lang.Range.map(closure) [/wollok.wlk:606] at [/test.wtest:5]

Why Wollok allow me to construct a range of doubles if i cannot do anything with it? My point here is being consistent, don't allow me to construct an invalid range of Doubles values or let me make range of nums to play with them.

fdodino commented 8 years ago

I added a native validate() method. Push pending.

fdodino commented 8 years ago

Solved in wdate branch