Why is the Documentation full of Conundrums?

I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them.

Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it?

What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for...

My friend said to me that this is a common thing you will have to do and they were right however...

What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms...

Are you asking me that? No. So why is that in the problem.

These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.

Well what the F do they want me to name it?

You can name it whatever you want.

What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for...

This looks like an exercise where you need to save multiple pieces of associated data based on some criteria.

My friend said to me that this is a common thing you will have to do and they were right however...

You have good taste in friends.

What are you asking me to do?

As the description says, "keep track of which kind of number was the largest".

those are math terms from 20+ years ago

Math is not the same as programming. It doesn't change. Technically they are math terms from "20+ years ago". They are concepts that are thousands of years old. The Fibonacci sequence is the newest of these. It was named over 800 years ago, but even then, was just a European discovery of a concept that had been known to non-Europeans for hundreds of years before that. But it's Europeans who typically impose their cultural nomenclature across science.

I have no idea how to classify those terms...

You aren't being asked to classify them. They're already classified. You're just being asked to identify the one that includes the largest number from the provided data.

Are you asking me that? No. So why is that in the problem.

I'm not sure what you're asking. Perhaps you should consult your friend again. They seem quite knowledgeable.

These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.

This has absolutely nothing to do with Swift. This would be a legitimate exercise in any language. There are some interesting follow-on questions that would involve useful things to know about in Swift.

They're asking you to give the _ variable a name, and it's entirely up to you what you call it; it's just a variable name.

The right-hand side was already given a name, numbers, and it represents the right-hand side of the information in the interestingNumbers array, i.e. the arrays of numbers.

The underscore represents the left-hand side of the data, i.e. the three String values: Prime, Fibonacci, and Square.

If you do this, you should see how it works:

	let interestingNumbers = [
		"Prime": [2, 3, 5, 7, 11, 13],
		"Fibonacci": [1, 1, 2, 3, 5, 8],
		"Square": [1, 4, 9, 16, 25]
		]
	var largest = 0
	var largestSet = ""
	for (dataset, numbers) in interestingNumbers {
		for number in numbers {
			if number > largest {
				largest = number
				largestSet = dataset
			}
		}
	}
	print ("largestSet '\(largestSet)' with value: \(largest)")

@SymphOmni It seems you didn't understand the goal of the exercise ?

The purpose is to let you discover through practice the basic Swift concepts. In the case the dictionaries, a very important type in Swift.

Here you may have noted that interestingNumbers is a dictionary: a series of entries, which are pairs called key (a string) and value (here an array), such as "Prime": [2, 3, 5, 7, 11, 13]

The example shows that in the for loop, you explore the dictionary but don't need to know what the key is (because you don't use).

as dark-as showed, if you need to use the key, change _ into a name as dataset, or key, or whatever you want.

In another exercise, you could also iterate over the dictionary like this:

let interestingNumbers = [
    "Prime": [2, 3, 5, 7, 11, 13],
    "Fibonacci": [1, 1, 2, 3, 5, 8],
    "Square": [1, 4, 9, 16, 25]
]
var largest = 0
var largestSet = ""

for aLine in interestingNumbers {  // get entries of dictionary as a whole
    for number in aLine.value {    // value is the array, for each entry line
        if number > largest {
            largest = number
            largestSet = aLine.key // The key (the name) of the entry line
        }
    }
}
print (largest, "in", largestSet)

More difficult to read, but exactly the same result.

25 in Square

Exercise yourself by finding the smallest…

Why is the Documentation full of Conundrums?
 
 
Q