Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about protocol-inheritance

Read more about protocol-inheritance

python (12.9k questions)

javascript (9.2k questions)

reactjs (4.7k questions)

java (4.2k questions)

java (4.2k questions)

c# (3.5k questions)

c# (3.5k questions)

html (3.3k questions)

Questions - protocol-inheritance

Computed property to sum numeric arrays in Swift

Task from book says: without calling reduce(_: _:) method, sum sequences of numbers by adding a computed property called sum. You should be able to use it like this: [3, 7, 7].sum // 17 [8....
test-img

mairo

arrays

swift

computed-properties

protocol-extension

protocol-inheritance

Votes: 0

Answers: 1

Latest Answer

[1...4].sum is working on an Array of ClosedRange ([...] mean "Array of..."). You meant: (1...4).sum. You also mean: var sum: Element { ... } rather than Any. If you want to make it even...
test-img

Rob Napier

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved