码迷,mamicode.com
首页 > 编程语言 > 详细

Day11 swift2.0-String

时间:2016-04-19 00:09:16      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

//                                      **Day 11

//                                      **swift 2.0  String

 

var arr = [1,"2",3.3]

print("\(arr)")

 

var dict = ["a":1,"b":2,"c":3]

(dict as NSDictionary).allKeys

(dict as NSDictionary).allValues

 

var string = "hello world!"

let range = string.startIndex..<string.startIndex.advancedBy(5)

 

string.replaceRange(range, with: "Hi")

 

string

 

print("\(string)")

 

let range2 = string.endIndex.advancedBy(-6)..<string.endIndex

 

string.substringWithRange(range2)

 

 

var animals = "\u{1F60E}hoho~"

animals.characters.count

 

var swift_string = "symbol2.0"

let string2 = swift_string + "ahaha~"

print("\(string2)")

 

swift_string

 

swift_string.appendContentsOf("addString")

 

print("\(swift_string)")

 

var i = 1

for  ; i <= 100 ;  {

    i*i

    i += 1

}

 

for var a = -6.28 ; a <= 6.28 ; a += 0.2 {

    sin(a)

    

    cos(a)

    

    tan(a)

    

    1/tan(a)

}

 

var newstring = "hello world!"

for var c in newstring.characters {

    print("\(c)")

    

    if c == "r" {

        c = " "

        print("\(newstring.endIndex)")

    }

    print("\(c)")

}

 

print("\(newstring)")

Day11 swift2.0-String

标签:

原文地址:http://www.cnblogs.com/tony0571/p/5406207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!