Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
7
Task/Break-OO-privacy/Nim/break-oo-privacy-1.nim
Normal file
7
Task/Break-OO-privacy/Nim/break-oo-privacy-1.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
type Foo* = object
|
||||
a: string
|
||||
b: string
|
||||
c: int
|
||||
|
||||
proc createFoo*(a, b, c): Foo =
|
||||
Foo(a: a, b: b, c: c)
|
||||
3
Task/Break-OO-privacy/Nim/break-oo-privacy-2.nim
Normal file
3
Task/Break-OO-privacy/Nim/break-oo-privacy-2.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var x = createFoo("this a", "this b", 12)
|
||||
|
||||
echo x.a # compile time error
|
||||
1
Task/Break-OO-privacy/Nim/break-oo-privacy-3.nim
Normal file
1
Task/Break-OO-privacy/Nim/break-oo-privacy-3.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo repr(x)
|
||||
11
Task/Break-OO-privacy/Nim/break-oo-privacy-4.nim
Normal file
11
Task/Break-OO-privacy/Nim/break-oo-privacy-4.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import typeinfo
|
||||
|
||||
for key, val in fields(toAny(x)):
|
||||
echo "Key ", key
|
||||
case val.kind
|
||||
of akString:
|
||||
echo " is a string with value: ", val.getString
|
||||
of akInt..akInt64, akUint..akUint64:
|
||||
echo " is an integer with value: ", val.getBiggestInt
|
||||
else:
|
||||
echo " is an unknown with value: ", val.repr
|
||||
15
Task/Break-OO-privacy/Sidef/break-oo-privacy.sidef
Normal file
15
Task/Break-OO-privacy/Sidef/break-oo-privacy.sidef
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
class Example {
|
||||
has public = "foo"
|
||||
method init {
|
||||
self{:private} = "secret"
|
||||
}
|
||||
}
|
||||
|
||||
var obj = Example();
|
||||
|
||||
# Access public attributes
|
||||
say obj.public; #=> "foo"
|
||||
say obj{:public}; #=> "foo"
|
||||
|
||||
# Access private attributes
|
||||
say obj{:private}; #=> "secret"
|
||||
Loading…
Add table
Add a link
Reference in a new issue