i went through the railstutorial and saw the next one liner
('a'..'z').to_a.shuffle[0..7].join
it creates a random 7-character domain name, for example the following:
hwpcbmze.heroku.com
seyjhflo.heroku.com
jhyicevg.heroku.com
I tried converting one liner to groovy, but I could only come up with:
def range = ('a'..'z')
def tempList = new ArrayList (range)
Collections.shuffle(tempList)
println tempList[0..7].join()+".heroku.com"
Can this be improved and done on one liner? I tried to make the code above shorter
println Collections.shuffle(new ArrayList ( ('a'..'z') ))[0..7].join()+".heroku.com"
However, apparently, Collections.shuffle(new ArrayList ( ('a'..'z') ))isnull
source
share