https://gist.github.com/3746850 result.
def main():
x1=1
x2=1
def func1():
y1=x1+10 # x1 is in "enclosing function's scope"
https://gist.github.com/3746850 result.
def main():
x1=1
x2=1
def func1():
y1=x1+10 # x1 is in "enclosing function's scope"
var person = require("./Person") | |
var p = new person.Person('John'); | |
p.show(); | |
console.log("direct access: " + p.name); |
class Dynamic: | |
def __setattr__(self, name, value): | |
self.__dict__[name] = value | |
def __getattr__(self, name): | |
return self.__dict__[name] | |
d = Dynamic() | |
d.hoge = 'bar' | |
d.neko = 'nyan' |
//例えば非同期処理のcallback関数などにあえて関数名をつけるのはどうだろう? | |
someAjaxFunction("parmaeter", | |
function 販売価格の取得に成功した時(calculatedSalesPrice){ | |
console.log(calculatedSalesPrice); | |
}, | |
function なんかエラー(e){ | |
console.log(e); | |
} | |
); | |
//変更前 |
trait Weapon {
val strength: Int
}
scalac後javapで表示
$ javap -c Weapon
Compiled from "test.scala"
public interface Weapon {
public abstract int strength();
import collections | |
import re | |
text = "I have a pen. I have a apple. oh!! Apple pen! I have a pen. I have a pineapple. oh!! Pineapple pen! Apple pen. Pineapplepen. Pen pineapple apple pen." | |
collections.Counter(s.lower() for s in re.split(r'[^\w]+',text)) |