2014年8月20日水曜日

開発環境

Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 8(Storing Collections of Data Using Array)、8.9(Exercises) 1-a, b, c, d, e, f.をSwiftで考えてみる。

8.9(Exercises) 1-a, b, c, d, e, f.

コード(Xcode)

main.swift

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

import Foundation

let kingdom:[String] = ["Bacteria", "Protozoa", "Chromista", "Plantae", "Fungi", "Animalia"]
let empty:[String] = []

println(kingdom[0])

println(kingdom[5])

println(kingdom[0...2])

println(kingdom[2...4])

println(kingdom[4...5])

println(empty)

入出力結果(Console Output)

Bacteria
Animalia
[Bacteria, Protozoa, Chromista]
[Chromista, Plantae, Fungi]
[Fungi, Animalia]
[]
Program ended with exit code: 0

0 コメント:

コメントを投稿