swift-style-guide icon indicating copy to clipboard operation
swift-style-guide copied to clipboard

What should we do about constants?

Open Haud opened this issue 9 years ago • 3 comments

Discussion emerged as to how we should handle constants in Swift. Should they be in enums? Structs? Globals? Some other thing we're not aware of?

Do we have any resources that have a strong drive one way or the other? I cannot find any, and until we do, I vote we should avoid ruling on it until we have a good reason to encourage / discourage one use case over the other.

This is one resource: http://www.jessesquires.com/swift-namespaced-constants/

Haud avatar Feb 01 '16 22:02 Haud

The approach shown by jessesquires is informative and innovative in handling resources, but I think R.swift pod is also a good competitor for managing resources.

ayushcshah avatar Apr 04 '16 08:04 ayushcshah

@ayushcshah thanks for the feedback! That pod is pretty interesting, though I don't think it would make sense as part of the style guide. I think what we're seeing is that there are multiple valid routes; I've read that post by jessesquires before as well, and it's definitely informative but I don't feel it's necessarily definitive, if that makes any sense

Haud avatar Apr 14 '16 15:04 Haud

Yup, makes sense.

ayushcshah avatar Apr 15 '16 16:04 ayushcshah