Programming in Swift: Functions & Types, Episode 33: Methods |

Take a deep dive into methods, including writing initializers, mutating methods, and more. Work with structures and enumerations!

This is a companion discussion topic for the original entry at

tons of new concepts not necessarily related to the topic, no purpose. It’s hard for me to imagine someone who smoothly sits by himself and thinks it all up, since you don’t know what the goal is.

The temp of speech is too fast for me. Pauses and subtitles didn’t do much help. After watching the video I need to read more about mutating and non-mutating functions once again.

When to use case-less enumerations, and when we don’t need it?

Hi, Catie. In this course, you introduced the concept of “case-less enumeration”. Just want to make sure, why it doesn’t make sense to write code like this when we can call the method after math?

struct Mathematics {
  func getLength(x: Double, y: Double) -> Double {

let math = Mathematics()
math.getLength(x: 3.0, y: 4.0) // 5.0

If let math = Mathematics() doesn’t make sense in this case, when would we need to write code like this?

struct Mathematics {
  // What kind of code will make sense here? 
  // If there is only one method that doesn't take any parameter? 
  // If there are multiple methods? 
  // If it only contains properties?
  // Or if it contains properties in it along with methods?

let math = Mathematics()

I would really appreciated if you can help we clarify the concept. Besides, because English is not my native language, if there’s anything I wrote that is hard to read or sounds offensive, I don’t mean that and I apologize for that. Thank you.