Lichen

Changeset

823:a4df5857763a
2018-01-16 Paul Boddie raw files shortlog changelog graph Added an example of initialising parameters with defaults.
docs/wiki/Design (file)
     1.1 --- a/docs/wiki/Design	Mon Jan 15 23:16:44 2018 +0100
     1.2 +++ b/docs/wiki/Design	Tue Jan 16 22:27:11 2018 +0100
     1.3 @@ -147,7 +147,18 @@
     1.4          pass
     1.5  }}}
     1.6  
     1.7 -Naturally, `self` can also be omitted from such parameter lists.
     1.8 +Naturally, `self`, being a reserved name in methods, can also be omitted from such parameter lists. Moreover, such initialising parameters can have default values.
     1.9 +
    1.10 +{{{#!python numbers=disable
    1.11 +class C:
    1.12 +    def __init__(.a=1, .b=2):
    1.13 +        pass
    1.14 +
    1.15 +c1 = C()
    1.16 +c2 = C(3, 4)
    1.17 +print c1.a, c1.b # 1 2
    1.18 +print c2.a, c2.b # 3 4
    1.19 +}}}
    1.20  
    1.21  == Inheritance and Binding ==
    1.22