Skip to content

Instantly share code, notes, and snippets.

@nelhage
Created March 27, 2017 01:53
Show Gist options
  • Save nelhage/13d160fa4d956d989862ed9c28735ddb to your computer and use it in GitHub Desktop.
Save nelhage/13d160fa4d956d989862ed9c28735ddb to your computer and use it in GitHub Desktop.
split
$ ruby -e 'puts ("".split(" ")).inspect'
[]
$ perl -MData::Dumper -E 'say Dumper([split(" ", "")])'
$VAR1 = [];
$ python -c 'print "".split(" ")'
['']
# https://play.golang.org/p/qErK71KCsF
$ echo 'package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.Split(" ", ""))
}
' > split.go; go run split.go
[ ]
$ echo 'class Split {
> public static void main(String []args) {
> String[] bits = "".split(" ");
> System.out.print("[");
> for (String b : bits) {
> System.out.print("\"" + b + "\" ");
> }
> System.out.println("]");
> }
> }
> ' > split.java && javac split.java && java Split
["" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment