Is there a shorthand way of writing a range type in Swift? -


so knowledge of swift there convenience syntaxes/shorthand ways of defining types can shorten types parameters in functions.

e.g. array,

func example(anarray: array<int>) {} 

can more written

func example(anarray: [int]) {} 

or dictionary,

func example2(adictionary: dictionary<string, int>) {} 

can more written

func example2(adictionary: [string: int]) {} 

i wondering if there shorthand way available range, or following way write it? not long write way, i'm more curious!

func example3(arange: range<int>) {} 

edit:

the range operators used creating ranges, not used define type.

if write

let arr  = [0, 1, 2] let dict = [0:0, 1:1, 2:2] let range= 0...2 

and inspect 3 variables' types, for:

  • arr let arr: [int]
  • dict let dict: [int : int]
  • range let range: range<int>

which leads me beleive there no shorthand defining range type in swift.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -