2014年8月3日日曜日

開発環境

Head First JavaScript Programming (Eric T. Freeman (著)、 Elisabeth Robson (著)、 O'Reilly Media )のChapter 4(Putting Some Order in Your Data: Arrays)、SHARPEN YOUR PENCIL(p.130)をSwiftで考えてみる。

SHARPEN YOUR PENCIL(p.130)

コード(Xcode)

main.swift

//
//  main.swift
//  sample130
//
//  Created by kamimura on 8/3/14.
//  Copyright (c) 2014 kamimura. All rights reserved.
//

import Foundation

var products:[String] = ["Choo Choo Chocolate", "Icy Mint", "Cake Batter", "Bubblegum"]

var last1 = products.count
var recent1 = products[last1 - 1]

var last2 = products.endIndex
var recent2 = products[last2 - 1]

println(recent1)
println(recent2)

入出力結果(Console Output)

Bubblegum
Bubblegum
Program ended with exit code: 0

0 コメント:

コメントを投稿