class SmallSample
var _random = Random()
def randomString(length as int, alphabet as String) as Stringrequire
length > 0
alphabet <> ''ensure
result.length == length
test
utils = SmallSample()
assert utils.randomString(5, 'ab').length == 5
s = utils.randomString(1000, 'a')
for c in s, assert c == 'a'body
sb = StringBuilder()
for i in lengthc = alphabet[_random.next(alphabet.length)]
sb.append(c)return sb.toString
def main
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for i in 10, print .randomString(10, alphabet)
- Clean, high-level syntax
- Static and dynamic binding
- First class support for unit tests and contracts
- Compiled performance with scripting conveniences
- Lambdas and closures
- Extensions and mixins
- ... and more
2013-12-23
2013-05-24
2012-09-26
2012-09-25
2012-07-25
2012-06-30
2012-06-21