We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e4720e commit bd78fe1Copy full SHA for bd78fe1
_data/new-data/landing/callouts.yml
@@ -19,23 +19,17 @@
19
code: |-
20
import ArgumentParser
21
22
- @main
23
- struct Describe: ParsableCommand {
+ // Complete implementation of a command line tool
+ @main struct Describe: ParsableCommand {
24
@Argument(help: "The values to describe.")
25
var values: [Double] = []
26
27
mutating func run() {
28
values.sort()
29
let total = values.reduce(0, +)
30
- let smallest =
31
- if let first = values.first {
32
- "\(first)"
33
- } else {
34
- "No value"
35
- }
36
-
+
37
print("""
38
- Smallest: \(smallest)
+ Smallest: \(values.first, default: "No value")
39
Total: \(total)
40
Mean: \(total / Double(values.count))
41
""")
0 commit comments