38 lines
429 B
Plaintext
38 lines
429 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
public class Foo {
|
||
|
private var foo : String
|
||
|
|
||
|
public func getFoo() -> String {
|
||
|
return foo
|
||
|
}
|
||
|
|
||
|
//...
|
||
|
|
||
|
}
|
||
|
|
||
|
var foo = Foo()
|
||
|
foo.getFoo() // what does this return?
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
public class Foo {
|
||
|
private var name : String
|
||
|
|
||
|
public func getName() -> String {
|
||
|
return name
|
||
|
}
|
||
|
|
||
|
//...
|
||
|
|
||
|
}
|
||
|
|
||
|
var foo = Foo();
|
||
|
foo.getName()
|
||
|
----
|