-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexample.vy
More file actions
57 lines (45 loc) · 837 Bytes
/
example.vy
File metadata and controls
57 lines (45 loc) · 837 Bytes
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
# @version 0.3.9
NUMBER: constant(uint256) = 30
@view
@external
def is_active(_index: uint256) -> bool:
"""
@notice if-else 控制流语句
"""
if _index > 1:
return True
elif _index == 1:
return False
else:
return False
@view
@external
def sum_numbers() -> uint256:
total: uint256 = 0
for i in range(0, 30):
total += i
return total
@view
@external
def sum_numbers1() -> uint256:
total: uint256 = 0
for i in range(0, NUMBER):
total += i
return total
# @view
# @external
# def sum_numbers_error(_number: uint256) -> uint256:
# """
# @notice 错误写法
# """
# total: uint256 = 0
# for i in range(0, _number):
# total += i
# return total
@view
@external
def get_max(_a: uint256, _b: uint256) -> uint256:
"""
@notice 三元运算
"""
return _a if _a > _b else _b