Skip to content

Latest commit

History

History
120 lines (79 loc) 路 1.41 KB

File metadata and controls

120 lines (79 loc) 路 1.41 KB

EXTENSION

Int

public extension Int

Properties

isOdd

var isOdd: Bool

Whether self is an odd number

isEven

var isEven: Bool

Whether self is an even number

nilIfZero

var nilIfZero: Int?

Treats 0 as nil

string

var string: String

Make the number to string

range

var range: CountableRange<Int>

Make a range from zero to self

hours

var hours: Int

minutes

var minutes: Int

days

var days: Int

months

var months: Int

years

var years: Int

Methods

instances(of:)

func instances<T>(of creation: @autoclosure () throws -> T) rethrows -> [T]

Return a number of instances

  • Parameter creation: The initialization of the object
  • Returns: An array containing the objects

Parameters

Name Description
creation The initialization of the object

inRange(_:)

func inRange(_ range: Range<Int>) -> Bool

Return if self is in the given range.

  • Parameter range: Target range.
  • Returns: true if self is in the range, otherwise false.

Parameters

Name Description
range Target range.

times(block:)

func times(block: () -> Void)

Calls the given block n number of times.