-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.np
117 lines (94 loc) · 2.55 KB
/
sample.np
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//Notepad サンプル
//七瀬さんが提示したやつ
scr:
rcs
class Person extends Animal:
instance age=0;
def show_age():
//if
if age>=0:
Stdio.print("Hello,#{age}");
else:
print("invalid");
fi
fed
ssalc
module s:
//先頭に public protected private のアクセス修飾子を付加できます
class Sample:
instance name = 0; //インスタンス変数
class huga = 0; //クラス(static)変数
prop A(private,private)= 1;
//特に何も指定しなくてもpublic メソッドです
public def public_method:
print("Hello,public method!");
fed
//protected メソッド
protected def protected_method(a):
print("Hello,protected method:#{a}");
fed
//private メソッド
private def private_method():
print("Don't be shy");
fed
//とりあえずself
def hello(name):
self.name=name;
print("Hello,#{self.name}");
fed
//if文、elifにも対応
def show_age(age):
if age>=0 :
print("Your age is #{age}");
else:
print("Invalid!");
fi
fed
//for文
def for_sample():
for i in array:
print(i);
rof
fed
def while_and_unless_sample:
while true:
"∞"; //ぶっちゃけ値だけ書いても怒られません
elihw
unless true:
"NOOOOO";
sselnu
fed
//for,while,unlessに関しては将来的に単文でも書けるようになる予定です
//2014/09/03 なりました
def switch_sample:
local base=1;
switch base:
case 0:
print("yay!");
case 1:
//Notepadはfall-troughできません
case 2:
default:
hctiws
fed
//if文は先行的に別の書き方を実装
def if_extra:
print("後置if") if true;
if false : print("1行if");
fed
def value_if:
print(("yes" else "no" in false));
fed
native def non_virtual_method:
"このメソッドはオーバーライドできず、仮想関数テーブルを定義しません";
fed
ssalc
//もちろん継承もサポート
protected class Derived extends Sample:
//オーバーライド時には必ずovriキーワードを付加
//引数の種類(将来的に実装)とか順番が合ってれば名前は違っても大丈夫
private override def hello(namae):
print("こんにちは、#{namae}さん");
fed
ssalc
eludom