This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var someFunc = function() {}; | |
| function f() { | |
| var some = new someFunc(); // this won't be garbage collected!!! | |
| function unreachable() {}; | |
| return function() {}; | |
| } | |
| window.f_ = f(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Foo<'self> { | |
| name: ~str, | |
| ref_bar: &'self Bar // Bar lives as long as Foo | |
| // When Foo is freed, Bar is freed | |
| // No memory leaks! | |
| } | |
| struct Bar { | |
| name: ~str | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a := []int{1,2,3} | |
| b := []int{4,5,6} | |
| // Bad way | |
| for _, number := range b { | |
| a = append(a, number) | |
| } | |
| // Super awesome way | |
| a = append(a, b...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for key, val in dictionary.iteritems(): | |
| print key, val | |
| for key in dictionary.iterkeys(): | |
| print key | |
| for val in dictionary.itervalues(): | |
| print val |
NewerOlder