SassList

Swift
public class SassList: SassValue

A Sass list value.

Sass lists have a separator and may be surrounded with brackets. All Sass values can be treated as lists so much list-like behavior is available via SassValue. SassList is mostly useful for constructing your own multi-element lists.


Topics

Types

enum Separator

The list-separator character.

Declaration
Swift
public enum Separator: String, Equatable, Sendable

Initializers

init<C>(C, separator: Separator, hasBrackets: Bool)

Initialize a new list with the contents of a Swift sequence.

Declaration
Swift
public init<C>(
    _ sequence: C, separator: Separator = .space, hasBrackets: Bool = true)
where C: Sequence, C.Element == SassValue
Parameters
sequence

The SequenceSequence whose contents should be copied into the list.

separator

The separator character to use in any CSS generated from the list. If sequence contains more than one element then an .undecided separator is promoted to .space.

hasBrackets

Whether the list should display with brackets. Normally true.

Properties

var separator: Separator

The list separator.

Declaration
Swift
public override var separator: Separator { get }

var hasBrackets: Bool

Does the list have brackets?

Declaration
Swift
public override var hasBrackets: Bool { get }

var listCount: Int

The number of values in this value viewed as a list.

Declaration
Swift
public override var listCount: Int { get }

Methods

func valueAt(sassIndex: SassValue) -> SassValue

Subscript the value using a Sass list index.

(Swift can’t throw exceptions from subscript).

Declaration
Swift
public override func valueAt(sassIndex: SassValue) throws -> SassValue
Parameters
sassIndex

A Sass value intended to be used as an index into this value viewed as a list. This must be an integer between 1 and the number of elements inclusive, or a negative number with similar magnitude to index back from the end.

Throws

SassFunctionError if sassIndex is not an integer or out of range.

Return Value

The value at the Sass index.

Misc

static func ==(lhs: SassList, rhs: SassList) -> Bool

List equality: all empty SassLists are equal. Non-empty lists are equal iff they have the same separator, brackets, and contents.

Declaration
Swift
public static func == (lhs: SassList, rhs: SassList) -> Bool

func hash(into: inout Hasher)

Hashes the list’s properties and contents.

Declaration
Swift
public override func hash(into hasher: inout Hasher)

func makeIterator() -> AnyIterator<SassValue>

An iterator for the values in the list.

Declaration
Swift
public override func makeIterator() -> AnyIterator<SassValue>

func accept<V, R>(visitor: V) -> R

Call the corresponding method of visitor against this object.

Declaration
Swift
public override func accept<V, R>(visitor: V) throws -> R
where V: SassValueVisitor, R == V.ReturnType

var description: String

A short description of the value.

Declaration
Swift
public override var description: String { get }