test golang Flashcards

1
Q

method

A

<p>function w/ a receiver as an extra parameter</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

method declaration

A

<p>func RECIEVER NAME SIGNATURE {<br></br>STMT+<br></br>}</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

method declaration

A

<ul><li>Likely should use method declaration (syntax) w/ pointer receivers b/c Can modify the receiver pointed to, efficiency</li><li>In method "gracefully" handle nil reciever</li></ul>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

receiver

A

<p>(VARDECL)</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

method expression

A

<p>RECIEVER.METHOD</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

interfaces in Tour

A

<p></p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

append

A

<p>Always use return value b/c May create new slice in the process</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

array/slice

A

<ol><li>(Optional) Either<ul><li>array declaration (syntax)</li><li>Implicit declare</li></ul></li><li>(Optional) Initialize w/ either<ul><li>Specify array literal</li><li>make (syntax)</li></ul></li><li>Until done do any<ul><li>Slice expression (syntax)</li><li>Indexing expression (syntax)</li><li>append (user)</li></ul></li></ol>

<p></p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

interface

A

<p>method set of an interface type</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

method set

A

<p>For some type T, is all methods declared w/ receiver type T</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

implement the interface

A

<p>A type T implements an interface I if and only if T has a method set that is a superset of I</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

interface type

A

<p>Set of method signatures w/ variables of the type containing any value that implements the interface</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

interface type

A

<p>interface {<br></br>(METHODSPEC;|IFNAME;)+<br></br>}</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

interface type

A

<ol><li>If interface value has not been assigned a concrete type then invalid memory address run-time panic b/c Unable to determine which concrete method to call</li><li>Else if assigned a concrete type but underlying value is nil then a method call is conducted w/ nil receiver</li><li>Else method call w/ non-nil reciever</li></ol>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

interface type declaration

A

<p>type NAME INTERFACETYPE</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

empty interface

A

<p>Interface { }, implemented by all types and used in code that handles values of unknown type (e.g., fmt.Print)</p>

17
Q

embedded interface

A

<p>an interface type name E used in an interface declaration to include E's method set</p>

18
Q

static type

A

<p>For a variable, is type given at variable's declaration</p>

19
Q

dynamic type

A

<p>For a variable of an interface type, is the type of the value assigned at run-time</p>

20
Q

interface pointer receiver error

A

<p>cannot use ... literal (type ...) as type ... in assignment... does not implement ... (... method has pointer receiver)<br></br>Have not located explanation or requirement in ref spec</p>

21
Q

interface pointer receiver error

A

<ol><li>Use address operation to generate pointer</li></ol>