Skip to content

Instantly share code, notes, and snippets.

View giltayar's full-sized avatar

Gil Tayar giltayar

View GitHub Profile
function stringToArray(s) {
const retVal = [];
for (const ch of s) {
retVal.push(ch);
}
return retVal;
}
const str = 'H😀😀d';
const iterator = str[Symbol.iterator](); // get the iterator from string
iterator.next(); // skip over the 'H'
console.log(iterator.next().value); // get the first emoji
console.log(stringToArray('Robin Hoווd'));
console.log(stringToArray('Robin H😀😀d'));
@giltayar
giltayar / naive-iteration.js
Last active January 24, 2017 07:22
Unicode String Iteration Article Sample Code
function stringToArray(s) {
const retVal = [];
for (let i = 0; i < s.length; ++i) {
retVal.push(s[i]);
}
return retVal;
}
case class JsonableEither[+L, +R](left: Option[L] = None, right: Option[R] = None) {
require(left == None && right != None ||
left != None && right == None)
}