Problem with "Assigning a property to itself"

Hello guys,
i´m at the beginning of learning Swift and I don't get the following problem:

Why does this not work? It worked every time before, but not with "fellfarbe"

1 Like

You have a typo

Welcome to the Swift forums!

In your class, the property fellfarbe has a lowercase f in farbe, but the argument to the initializer is fellFarbe with a capital F. Since variable names are case-sensitive, the compiler treats them as different symbols.

(Edit: For English speakers, what follows is basically just a translation of @allevato’s last comment, with arrows added pointing to the relevant pieces of the original poster’s German source code.)


Es stimmt, was die anderen sagen:

var fellfarbe: Fellfarbe //
//      ↑
// Durch den folgenden Unterschied,
// weisen beide Seiten des Geichheitszeichens hier zurück.
// Daher die Warnung:
// „Eine Eigenschaft wird sich selbst zugewiesen.“

//                    ↓ Hier ist es großgeschrieben.
init(/* [...] */, fellFarbe: Fellfarbe) {
    self.fellfarbe = fellfarbe
    // [...]             ↑ Hier aber nicht.
}

Übrigens ist es schön deutschen Quelltext zu sehen!

1 Like

While the German answer is probably useful to the original poster, it is not useful for others reading this, and the OP has demonstrated that he understands English. Please keep this forum monolingual, or at least keep single threads in a single language.

5 Likes

This seems elitist and unhelpful. Multiple languages exist, and while it’s nice to have an English translation of any foreign language posts, providing an answer for the question should be the primary goal. We can do that without being exclusionary, which should be a secondary goal. In short, “Hey. Not cool.”

1 Like

Exactly. We should attempt to not be exclusionary. I'm not suggesting people refrain from asking questions in their native tongue, but that people refrain from changing the language mid-thread, which is effectively excluding everyone else. I'm sorry if that came off as elitist.

I (and maybe you) can clearly see that Jeremy provided a helpful answer in a polite and sweet tone. We can also see that his addition didn't add anything new to the conversation. But not everyone understands German, and to them, this thread took a sudden left turn, and there is no way for them to know wether we're now all talking about the same thing.

Note: I speak both English and German as secondary languages. Neither is my native tongue. However, I would feel pretty bummed if a thread I participated in took a turn for Russian, Japanese, Spanish or some other language I don't speak. I don't think it's elitist to ask people to be inclusive.

2 Likes

A separate topic has been opened to discuss the question of monolingualism or not. Anyone who has more to say on that subject is invited to do so there instead. Let’s keep this thread on topic.

3 Likes
Terms of Service

Privacy Policy

Cookie Policy