This is a bit of a random article. In conversation a coupla weeks back, a colleague questioned my approach to converting a string into an array of characters. Not questioned in a bad way, but my approach surprised them.
Anyway, this festered in my head for a coupla weeks, and popped back into it this morning on the train on the way into work.
I decided to ask you lot how you'd approach it.
Here's the requirement:
Consider this string:
nz = "Aotearoa";
What I want is to see how you'd approach turning that into an array of characters, ie: so if you dumped it you'd get this:
array | |
---|---|
1 | A |
2 | o |
3 | t |
4 | e |
5 | a |
6 | r |
7 | o |
8 | a |
Easy.
So as to not influence other people's answers, please don't post your answers as comments to this article, instead stick them in in this quick Survey Monkey survey. As suggested in the survey text: either post the code or give me a Gist or Pastebin URL or something.
I'll buy a beer for a random answer. It'll be an arbitrary decision, and final one ;-) Obviously as we're stationed all over the place, the beer will have to wait until we're in the same place at the same time.
I'll publish the code when I decide I've got as many responses as I'm likely to.
Cheers.
--
Adam