Skip to main content

RocketLang v0.16 is released

ยท 2 min read

Featuresโ€‹

HTTP builtin addedโ€‹

The HTTP builtin has been added which allows to create a builtin webserver and handle incoming requests.

See HTTP for more information.

Add Ability to marshal Objects to JSON Stringsโ€‹

You can now use .to_json() to various objects in order to convert them to their JSON respresentation.

See JSON for more information.

Support for Next and Breakโ€‹

Within a loop you can now use break and next for complex control flows.

foreach i in 5
if (i == 2)
next("next")
end
puts(i)
end

foreach i in 5
if (i == 2)
break("break")
end
puts(i)
end

// Returns

0
1
3
4
0
1
"break"

Allow String Multiplicationโ€‹

Support for repeating a string by a given number using the * operator has been added.

๐Ÿš€ > "test" * 2
=> "testtest"

Allow Integer Iterationโ€‹

info

Contribution by RaphaelPour

An Integer can now be iterated.

๐Ÿš€ > foreach i in 5 { puts(i) }
0
1
2
3
4
=> 5

Support for Modulo Operatorโ€‹

Modulo has been added as valid operator.

๐Ÿš€ > 5 % 3
=> 1

Support for Ternery Operatorโ€‹

It is now possible to use the ? operator.

๐Ÿš€ > 4 > 3 ? true : false
=> true

While Loopโ€‹

info

Contribution by MarkusFreitag

Support for while has been added.

๐Ÿš€ > a = 0
๐Ÿš€ > while (a != 4)
puts(a)
a = a + 1
end
// which prints
0
1
2
3
=> nil

Improvementsโ€‹

Add Shorthand to convert Float to Integerโ€‹

info

Contribution by RaphaelPour

The .plz_i() method has been added to the Float object.

๐Ÿš€ > a = 123.456
=> 123.456
๐Ÿš€ > a.plz_i()
=> 123

Fix Object Index and add support for Index Rangeโ€‹

info

Contribution by MarkusFreitag

The index operator [] has been fixed for many objects and now supports also ranges.

a = [1, 2, 3, 4, 5]
puts(a[2])
puts(a[-2])
puts(a[:2])
puts(a[:-2])
puts(a[2:])
puts(a[-2:])
puts(a[1:-2])

// should output
[1, 2]
[1, 2, 3]
[3, 4, 5]
[4, 5]
[2, 3]
[1, 2, 8, 9, 5]

Return written bytes on FILE.writeโ€‹

If you write to a file it now returns the written bytes instead of true.

Removedโ€‹