欠如

来世は貝になりたい

Swiftの文法について復習してみるObjects and Classes

ツアーもやっと中盤まで行きましたね 今回のテーマはObjects and Classes(オブジェクトとクラス)となります。

Objects and Classes

Use class followed by the class’s name to create a class. 
A property declaration in a class is written the same way as a constant or variable declaration, except that it is in the context of a class. 
Likewise, method and function declarations are written the same way.

クラスを作成するには、クラス名の後にクラスを使用します。
クラス内のプロパティ宣言は、クラスのコンテキスト内にあることを除いて、定数宣言または変数宣言と同じ方法で記述されます。
同様に、メソッドと関数の宣言も同じように記述されます。
class Shape {
    var numberOfSides = 10
    func simpleDescription() -> String {
        return "A shape with \(numberOfSides) sides."
    }
}
print(Shape().simpleDescription())

実行すると以下の通りになります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
A shape with 10 sides.
Create an instance of a class by putting parentheses after the class name. 
Use dot syntax to access the properties and methods of the instance.

クラス名の後に括弧を入れてクラスのインスタンスを作成します。
ドット構文を使用して、インスタンスのプロパティとメソッドにアクセスします。
var shape = Shape()
shape.numberOfSides = 7
var shapeDescription = shape.simpleDescription()

こちらはすでにひとつ前の例に組み込む形になりますが 上のfuncとclassを代入し使いやすくした形になります。 なので結果表示は割愛します。

This version of the Shape class is missing something important: 
an initializer to set up the class when an instance is created. 
Use init to create one.

このバージョンのShapeクラスには、インスタンスの作成時にクラスを設定するためのイニシャライザという重要なものがありません。
initを使用して作成します。
class NamedShape {
    var numberOfSides: Int = 0
    var name: String
    
    init(name: String) {
        self.name = name
    }
    init(){
        self.name = "damy"
    }
    
    func simpleDescription() -> String {
        return "A shape with \(numberOfSides) sides."
    }
}
let test = NamedShape(name:"abs")
print(test.name)
print(NamedShape().simpleDescription())

今回は一部引数を使わない用に引数なしで公式とは変更があります・ ちなみに実行すると以下のような結果が得られます

Linking ./.build/x86_64-unknown-linux/debug/TempCode
abs
A shape with 0 sides.
Notice how self is used to distinguish the name property from the name argument to the initializer. 
The arguments to the initializer are passed like a function call when you create an instance of the class. 
Every property needs a value assigned—either in its declaration (as with numberOfSides) or in the initializer (as with name).

nameプロパティとname引数を初期化子と区別するためにselfがどのように使用されているかに注目してください。
イニシャライザへの引数は、クラスのインスタンスを作成するときに関数呼び出しのように渡されます。
すべてのプロパティは、宣言(numberOfSidesの場合)またはイニシャライザ(nameの場合)のいずれかに値を割り当てる必要があります。
Use deinit to create a deinitializer if you need to perform some cleanup before the object is deallocated.

Subclasses include their superclass name after their class name, separated by a colon. 
There is no requirement for classes to subclass any standard root class, so you can include or omit a superclass as needed.

オブジェクトの割り当てが解除される前にいくつかのクリーンアップを実行する必要がある場合は、deinitを使用してdeinitializerを作成します。

サブクラスは、クラス名の後ろにコロンで区切られたスーパークラス名を含みます。
クラスが標準のルートクラスをサブクラス化する必要はないため、必要に応じてスーパークラスを含めるか省略することができます。
Methods on a subclass that override the superclass’s implementation are marked with override—
overriding a method by accident, without override, is detected by the compiler as an error. 
The compiler also detects methods with override that don’t actually override any method in the superclass.

スーパークラスの実装をオーバーライドするサブクラスのメソッドには、オーバーライドなしでメソッドが
オーバーライドされてマークされ、エラーとしてコンパイラによって検出されます。
また、コンパイラは、スーパークラスのメソッドを実際にオーバーライドしないオーバーライドを持つメソッドも検出します。
class Square: NamedShape {
    var sideLength: Double
    
    init(sideLength: Double, name: String) {
        self.sideLength = sideLength
        super.init(name: name)
        numberOfSides = 4
    }
    
    func area() -> Double {
        return sideLength * sideLength
    }
    
    override func simpleDescription() -> String {
        return "A square with sides of length \(sideLength)."
    }
}
let test = Square(sideLength: 5.2, name: "my test square")
test.area()
test.simpleDescription()

前例のNamedShape CLASSを継承し 実行結果は以下となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
27.04
A square with sides of length 5.2.
In addition to simple properties that are stored, properties can have a getter and a setter.

格納される単純なプロパティに加えて、プロパティにはゲッタとセッタがあります。
class EquilateralTriangle: NamedShape {
    var sideLength: Double = 0.0
    
    init(sideLength: Double, name: String) {
        self.sideLength = sideLength
        super.init(name: name)
        numberOfSides = 3
    }
    
    var perimeter: Double {
        get {
            return 3.0 * sideLength
        }
        set {
            sideLength = newValue / 3.0
        }
    }
    
    override func simpleDescription() -> String {
        return "An equilateral triangle with sides of length \(sideLength)."
    }
}
var triangle = EquilateralTriangle(sideLength: 3.1, name: "a triangle")
print(triangle.perimeter)
triangle.perimeter = 9.9
print(triangle.sideLength)

前例のNamedShape CLASSを継承し 実行結果は以下となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
9.3
3.3
In the setter for perimeter, the new value has the implicit name newValue. You can provide an explicit name in parentheses after set.

格納される単純なプロパティに加えて、プロパティにはゲッタとセッタがあります。
Notice that the initializer for the EquilateralTriangle class has three different steps:

1. Setting the value of properties that the subclass declares.
2. Calling the superclass’s initializer.
3. Changing the value of properties defined by the superclass. 
Any additional setup work that uses methods, getters, or setters can also be done at this point.

EquilateralTriangleクラスのイニシャライザには、次の3つのステップがあります。

1.サブクラスが宣言するプロパティの値を設定する。
2.スーパークラスの初期化子を呼び出す。
3.スーパークラスによって定義されたプロパティの値を変更する。
メソッド、ゲッター、またはセッターを使用する追加のセットアップ作業もこの時点で実行できます。
If you don’t need to compute the property but still need to provide code that is run before and after setting a new value, use willSet and didSet. 
The code you provide is run any time the value changes outside of an initializer. 
For example, the class below ensures that the side length of its triangle is always the same as the side length of its square.

プロパティを計算する必要はなく、新しい値を設定する前後に実行されるコードを提供する必要がある場合は、willSetとdidSetを使用します。
指定したコードは、イニシャライザの外部で値が変更されるたびに実行されます。
たとえば、以下のクラスは、三角形の辺の長さが常に四角形の辺の長さと同じであることを保証します。
class TriangleAndSquare {
    var triangle: EquilateralTriangle {
        willSet {
            square.sideLength = newValue.sideLength
        }
    }
    var square: Square {
        willSet {
            triangle.sideLength = newValue.sideLength
        }
    }
    init(size: Double, name: String) {
        square = Square(sideLength: size, name: name)
        triangle = EquilateralTriangle(sideLength: size, name: name)
    }
}
var triangleAndSquare = TriangleAndSquare(size: 10, name: "another test shape")
print(triangleAndSquare.square.sideLength)
print(triangleAndSquare.triangle.sideLength)
triangleAndSquare.square = Square(sideLength: 50, name: "larger square")
print(triangleAndSquare.triangle.sideLength)
Linking ./.build/x86_64-unknown-linux/debug/TempCode
10.0
10.0
50.0
When working with optional values, you can write ? before operations like methods, properties, and subscripting. 
If the value before the ? is nil, everything after the ? is ignored and the value of the whole expression is nil.
 Otherwise, the optional value is unwrapped, and everything after the ? acts on the unwrapped value. 
In both cases, the value of the whole expression is an optional value.

オプションの値を使って作業するときは? メソッド、プロパティ、およびサブスクリプトのような操作の前に。
?の前の値が? 無名:すべての後に? は無視され、式全体の値はnilになります。
  それ以外の場合、オプションの値はラップされず、? ラップされていない値に作用します。
どちらの場合も、式全体の値はオプションの値です。
let optionalSquare: Square? = Square(sideLength: 2.5, name: "optional square")
let sideLength = optionalSquare?.sideLength

以下が実行結果となります

Optional(2.5)

長くなりましたが続きは次回書きます。

Swiftの文法について復習してみる Functions and Closures

前回に引き続きツアーをやります

前回がfor in がwhile repeatなど制御などがテーマが今回は第三回目ということでテーマがFunctions and Closures(関数とクロージャ)となります。

クロージャ(クロージャー、英語: closure)、関数閉包はプログラミング言語における関数オブジェクトの一種。
いくつかの言語ではラムダ式や無名関数で実現している。
引数以外の変数を実行時の環境ではなく、自身が定義された環境(静的スコープ)において解決することを特徴とする。
関数とそれを評価する環境のペアであるともいえる。
この概念は少なくとも1960年代のSECDマシンまで遡ることができる。
まれに、関数ではなくとも、環境に紐付けられたデータ構造のことをクロージャと呼ぶ場合もある。
クロージャをサポートした言語のコーディングでは、関数の中に関数を定義することができる。
その際に、外側の関数で宣言された変数を内側の関数で操作することができる。主な利点としてはグローバル変数の削減が挙げられる。

Functions and Closures

Use func to declare a function. Call a function by following its name with a list of arguments in parentheses. 
Use -> to separate the parameter names and types from the function’s return type.

funcを使用して関数を宣言します。 カッコで囲まれた引数のリストを名前の後に付けて、関数を呼び出します。
 - >を使用して、関数の戻り値の型からパラメーター名と型を分離します。
func greet(person: String, day: String) -> String {
    return "Hello \(person), today is \(day)."
}
greet(person: "Bob", day: "Tuesday")
print(greet(person: "Bob", day: "Tuesday"))

下記が実行結果となります

Hello Bob, today is Tuesday.
By default, functions use their parameter names as labels for their arguments.
 Write a custom argument label before the parameter name, or write _ to use no argument label.

デフォルトでは、関数は引数のラベルとしてパラメータ名を使用します。 
パラメータ名の前にカスタム引数ラベルを記述するか、_を書いて引数ラベルを使用しないでください。
func greet(_ person: String, on day: String) -> String {
    return "Hello \(person), today is \(day)."
}
greet("John", on: "Wednesday")
print(greet("John", on: "Wednesday"))

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
Hello John, today is Wednesday.
Use a tuple to make a compound value—for example, to return multiple values from a function. 
The elements of a tuple can be referred to either by name or by number.

タプルを使用して複合値を作成します(たとえば、関数から複数の値を返すなど)。 タプルの要素は、名前または番号のいずれかで参照できます。
タプルとはプログラミングにおいて複数の値を組にしたものである。プログラミング言語によって多少異なるが、大体以下のような性質を持つ。

組にする値の型はバラバラで構わない。(リストや配列は中の要素が全て同じ型であることを要求される)
中の値は順序がある。(なければ集合の方が概念としては近いかもしれない)
長さ(中に入っている値の数)は固定で変更できない。(リストは長さが可変)
イミュータブルである。(リストや配列は特に指定のない限り、中の各要素は変更可能な場合が多い)
動的型付けの言語では、リストと区別されず長さや要素が変更可能なこともある。

func calculateStatistics(scores: [Int]) -> (min: Int, max: Int, sum: Int) {
    var min = scores[0]
    var max = scores[0]
    var sum = 0
    
    for score in scores {
        if score > max {
            max = score
        } else if score < min {
            min = score
        }
        sum += score
    }
    
    return (min, max, sum)
}
let statistics = calculateStatistics(scores: [5, 3, 100, 3, 9])
print(statistics.sum)
print(statistics.2)

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
120
120
Functions can be nested. Nested functions have access to variables that were declared in the outer function. 
You can use nested functions to organize the code in a function that is long or complex.

関数はネストできます。 
ネストされた関数は、外部関数で宣言された変数にアクセスできます。 
ネストされた関数を使用して、コードが長く複雑な関数で整理できます。
ネストとは、構造化プログラミングにおいてプログラムを構築する手法の一つで、あるルーチンやデータブロックの中に、別のルーチンやデータブロックがはめ込まれることである。入れ子構造とも呼ぶ。ループ文の中のループやルーチン内でにサブルーチンコール、関数呼び出しの引数に関数呼び出しを使うこと、コメントを含む文全体のコメント化など、多くの種類がある。
func returnFifteen() -> Int {
    var y = 10
    func add() {
        y += 5
    }
    add()
    return y
}
returnFifteen()

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
15
Functions are a first-class type. This means that a function can return another function as its value.

関数はファーストクラスの型です。 これは、関数が別の関数をその値として返すことができることを意味します。
func makeIncrementer() -> ((Int) -> Int) {
    func addOne(number: Int) -> Int {
        return 1 + number
    }
    return addOne
}
var increment = makeIncrementer()
increment(7)

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
8
A function can take another function as one of its arguments.

関数は引数の1つとして別の関数をとることができます。
func hasAnyMatches(list: [Int], condition: (Int) -> Bool) -> Bool {
    for item in list {
        if condition(item) {
            return true
        }
    }
    return false
}
func lessThanTen(number: Int) -> Bool {
    return number < 10
}
var numbers = [20, 19, 7, 12]
hasAnyMatches(list: numbers, condition: lessThanTen)

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
7
Functions are actually a special case of closures: blocks of code that can be called later. 
The code in a closure has access to things like variables and functions that were available in the scope where the closure was created, even if the closure is in a different scope when it is executed—you saw an example of this already with nested functions. 
You can write a closure without a name by surrounding code with braces ({}). 
Use in to separate the arguments and return type from the body.

関数は実際にはクロージャの特殊なケースです。後で呼び出すことができるコードのブロックです。
クロージャー内のコードは、クロージャーが作成されたスコープで使用可能な変数や関数のようなものにアクセスできます
(実行時にクロージャーが異なるスコープにあっても)。
囲むコードを中括弧({})で囲んで名前なしのクロージャーを書くことができます。
inを使用して、引数と戻り値の型を本文から切り離します。
numbers.map({ (number: Int) -> Int in
    let result = 3 * number
    return result
})

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
60
57
21
36
You have several options for writing closures more concisely. 
When a closure’s type is already known, such as the callback for a delegate, you can omit the type of its parameters, its return type, or both. 
Single statement closures implicitly return the value of their only statement.

クロージャをより簡潔に書くためのいくつかのオプションがあります。 
デリゲートのコールバックなど、クロージャの型がすでにわかっている場合は、そのパラメータの型、戻り型、またはその両方を省略できます。 
単一の文の終了は、唯一の文の値を暗黙的に返します。
let mappedNumbers = numbers.map({ number in 3 * number })
print(mappedNumbers)

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
[60, 57, 21, 36]
You can refer to parameters by number instead of by name—this approach is especially useful in very short closures. 
A closure passed as the last argument to a function can appear immediately after the parentheses.
 When a closure is the only argument to a function, you can omit the parentheses entirely.

名前ではなく番号でパラメータを参照することができます。
このアプローチは、非常に短いクロージャでは特に便利です。
 関数への最後の引数として渡されたクロージャは、かっこの直後に現れます。 
クロージャが関数の唯一の引数であるときは、かっこを完全に省略することができます。
let sortedNumbers = numbers.sorted { $0 > $1 }
print(sortedNumbers)

下記が実行結果となります

[20, 19, 12, 7]

長くなりましたが続きは次回やります

Swiftの文法について復習してみるControl Flow

前回に引き続きツアーをやりますね・・・

今回はControl Flow(制御の流れ)がテーマになります。

Control Flow

Use if and switch to make conditionals, and use for-in, while, and repeat-while to make loops. Parentheses around the condition or loop variable are optional. Braces around the body are required.

ifとswitchを使用して条件を作成し、for-in、while、およびrepeat-whileを使用してループを作成します。 条件変数またはループ変数の前後のかっこはオプションです。 身体の周りに括弧が必要です。

let individualScores = [75, 43, 103, 87, 12]
var teamScore = 0
for score in individualScores {
    if score > 50 {
        teamScore += 3
    } else {
        teamScore += 1
    }
}
print(teamScore)

実行結果は下記となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
11
In an if statement, the conditional must be a Boolean expression—this means that code such as if score { ... } is an error, not an implicit comparison to zero.

ifステートメントでは、条件式はブール式でなければなりません。つまり、score {...}がエラーであり、ゼロとの暗黙の比較ではありません。
You can use if and let together to work with values that might be missing. These values are represented as optionals. An optional value either contains a value or contains nil to indicate that a value is missing. Write a question mark (?) after the type of a value to mark the value as optional.

ifとletを使って、欠けているかもしれない値を扱うことができます。 これらの値はオプションとして表されます。 オプションの値には値が含まれているか、値がないことを示すnilが含まれています。 値の型の後に疑問符(?)を書き、値をオプションとしてマークします。
var optionalString: String? = "Hello"
print(optionalString == nil)
 
var optionalName: String? = "John Appleseed"
var greeting = "Hello!"
if let name = optionalName {
    greeting = "Hello, \(name)"
}

上記コードを実行すれば以下の通りになります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
false
Hello, John Appleseed
If the optional value is nil, the conditional is false and the code in braces is skipped. Otherwise, the optional value is unwrapped and assigned to the constant after let, which makes the unwrapped value available inside the block of code.

オプションの値がnilの場合、条件はfalseで、カッコ内のコードはスキップされます。 それ以外の場合は、オプションの値がラップされ、letの後に定数に代入されます。これにより、アンラップされた値がコードブロック内で使用可能になります。
Another way to handle optional values is to provide a default value using the ?? operator. If the optional value is missing, the default value is used instead.

オプションの値を処理するもう1つの方法は、??を使用してデフォルト値を指定することです。 オペレーター。 オプションの値がない場合は、代わりにデフォルト値が使用されます。
let nickName: String? = nil
let fullName: String = "John Appleseed"
let informalGreeting = "Hi \(nickName ?? fullName)"

実行すれば以下の通りになります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
Hi John Appleseed
Switches support any kind of data and a wide variety of comparison operations—they aren’t limited to integers and tests for equality.

スイッチは、あらゆる種類のデータと多種多様な比較演算をサポートします。整数と同等性のテストに限定されません。
import Foundation
let vegetable = "red pepper"
switch vegetable {
case "celery":
    print("Add some raisins and make ants on a log.")
case "cucumber", "watercress":
    print("That would make a good tea sandwich.")
case let x where x.hasSuffix("pepper"):
    print("Is it a spicy \(x)?")
default:
    print("Everything tastes good in soup.")
}

hasSuffix:接尾が一致 => true

実行すれば以下の通りになります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
Is it a spicy red pepper?
Notice how let can be used in a pattern to assign the value that matched the pattern to a constant.

After executing the code inside the switch case that matched, the program exits from the switch statement. Execution doesn’t continue to the next case, so there is no need to explicitly break out of the switch at the end of each case’s code.

You use for-in to iterate over items in a dictionary by providing a pair of names to use for each key-value pair. Dictionaries are an unordered collection, so their keys and values are iterated over in an arbitrary order.

どのパターンがパターンに使用され、パターンに一致する値を定数に割り当てるかに注目してください。

一致したスイッチケース内のコードを実行した後、プログラムはswitch文を終了します。 実行は次のケースに進むことはないので、各ケースのコードの終わりにスイッチから明示的に抜け出す必要はありません。

for-inを使用して、各キーと値のペアに使用する名前のペアを提供することによって、ディクショナリ内の項目を反復処理します。 辞書は並べ替えられていないコレクションなので、キーと値は任意の順序で反復されます。
let interestingNumbers = [
    "Prime": [2, 3, 5, 7, 11, 13],
    "Fibonacci": [1, 1, 2, 3, 5, 8],
    "Square": [1, 4, 9, 16, 25],
]
var largest = 0
for (kind, numbers) in interestingNumbers {
    for number in numbers {
        if number > largest {
            largest = number
        }
    }
}
print(largest)

実行すれば以下の通りになります

/swift-execution/Sources/main.swift:7:6: warning: immutable value 'kind' was never used; consider replacing with '_' or removing it
for (kind, numbers) in interestingNumbers {
     ^~~~
     _
Linking ./.build/x86_64-unknown-linux/debug/TempCode
25

numbersで配列を取得しその後numberで配列内のデータを一件ずつ取得しています

Use while to repeat a block of code until a condition changes. The condition of a loop can be at the end instead, ensuring that the loop is run at least once.

whileを使用して、条件が変わるまでコードブロックを繰り返します。 代わりにループの状態を最後に置いて、ループが少なくとも1回実行されるようにすることができます。
var n = 2
while n < 100 {
    n *= 2
}
print(n)
 
var m = 2
repeat {
    m *= 2
} while m < 100
print(m)

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
128
128
You can keep an index in a loop by using ..< to make a range of indexes.

インデックスの範囲を作成するには、.. <を使用してループ内のインデックスを保持することができます。
var total = 0
for i in 0..<4 {
    total += i
}
print(total)

下記が実行結果となります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
6
Use ..< to make a range that omits its upper value, and use ... to make a range that includes both values.

.. <を使用して上限値を省略した範囲を作成し、...を使用して両方の値を含む範囲を作成します。

長くなりましたが今回は以上となります

Swiftの文法について復習してみるSimple Values

基本はSwift4のReferenceをベースに勉強していきます。

実行環境

IBM Swift Sandbox

swift.sandbox.bluemix.net

Swift-Ver:Swift Dev. 4.0 (Aug 15, 2017) Platform: Linux (x86_64)

About Swift Swiftについては割愛します。

A Swift Tour ツアーですね。 refarenceの学習も兼ねているので、ここから読み解いていこうと思います。

Tradition suggests that the first program in a new language should print the words “Hello, world!” on the screen. 
In Swift, this can be done in a single line:

訳:新しい言語の最初のプログラムは、画面上に “こんにちは、世界!”という単語を印刷する必要があることを示唆しています。 Swiftでは、これは1行で行うことができます(google翻訳

print(“Hello, world!”)と入力すれば“Hello, world!”と文字列が出力されます。

下記が実行結果です。

Swift Dev. 4.0 (Aug 15, 2017)
Platform: Linux (x86_64)
Linking ./.build/x86_64-unknown-linux/debug/TempCode
Hello,World!

Simple Values

Use let to make a constant and var to make a variable. 
The value of a constant doesn’t need to be known at compile time, but you must assign it a value exactly once. 
This means you can use constants to name a value that you determine once but use in many places.

訳: letを使って変数を作る定数とvarを作る。定数の値はコンパイル時には知る必要はありませんが、一度だけ値を代入する必要があります。 これは、定数を使用して一度決定する値の名前を指定できますが、多くの場所で使用できます。(google翻訳

var test_t = 45
      test_t = 78
let  test_h = 75

print(test_t)
print(test_h)

上記にletを使って変数を作る定数とvarを作りその後定数の値を一時的に変更しました。 実行結果は下記になります。

Linking ./.build/x86_64-unknown-linux/debug/TempCode
78
75
A constant or variable must have the same type as the value you want to assign to it. 
However, you don’t always have to write the type explicitly. 
Providing a value when you create a constant or variable lets the compiler infer its type. 
In the example above, the compiler infers that myVariable is an integer because its initial value is an integer. 

訳:

定数または変数は、割り当てたい値と同じ型でなければなりません。
ただし、必ずしも型を明示的に記述する必要はありません。
定数または変数を作成するときに値を指定すると、コンパイラはその型を推論できます。
上記の例では、コンパイラは、初期値が整数なので、myVariableは整数であると推定します。

上記に英文の場合myVariableに当たるのがvarの定数が整数であると推測します。

If the initial value doesn’t provide enough information (or if there is no initial value), specify the type by writing it after the variable, separated by a colon. 

訳:

初期値が十分な情報を提供しない場合(または初期値がない場合)は、変数の後ろにコロンで区切って記述して型を指定します。
var test_Integer = 45
    //test_Double = 78.0
let practice_Double:Double = 75.9

print(practice_Double)

上記のように入力し実行すれば下記になります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
75.9

また、test_Doubleをコメントアウトは整数型のため小数点以下の数値を扱うためにはDouble型に変換しない場合エラーとなります。

Values are never implicitly converted to another type. If you need to convert a value to a different type, explicitly make an instance of the desired type. 

訳:

値は暗黙のうちに別の型に変換されることはありません。値を別の型に変換する必要がある場合は、明示的に目的の型のインスタンスを作成します。

let width = 300
let color = "blue :"
let sky = color + String(width)
print(sky)

上記コードを実行すれば以下の通りになります。

Linking ./.build/x86_64-unknown-linux/debug/TempCode
blue :300

また数値+数値や文字列+文字列なら出来ますが数値と文字列と処理を行う場合数値を文字列もしくは文字列を数値に変換する必要があります。

There’s an even simpler way to include values in strings: Write the value in parentheses, and write a backslash (\) before the parentheses. For example:

訳:

文字列に値を含めるさらに簡単な方法があります。値をかっこで書き出し、かっこの前にバックスラッシュ(\)を書きます。
let balls = 3
let coins = 5
let ballSummary = "I have \(balls) balls."
let allSummary = "I have \(balls + coins) PRICE."

print(ballSummary)
print(allSummary)

上記のように入力し実行すれば下記になります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
I have 3 balls.
I have 8 PRICE.
Use three double quotes (""") for strings that take up multiple lines. Indentation at the start of each quoted line is removed, as long as it matches the indentation of the closing quote. For example: 

訳:

複数の行を取る文字列には3つの二重引用符( "")を使います。引用符で囲まれた行の先頭にあるインデントは、閉じた引用符のインデントに一致する限り削除されます。
let balls = 3
let coins = 5
let quotation = """
Even though there's whitespace to the left,
the actual lines aren't indented.
Except for this line.
Double quotes (") can appear without being escaped.
 
I still have \(balls + coins ) pieces of fruit.
"""
print(quotation)

上記のように入力し実行すれば下記になります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
Even though there's whitespace to the left,
the actual lines aren't indented.
Except for this line.
Double quotes (") can appear without being escaped.
 
I still have 8 pieces of fruit.

There’s an even simpler way to include values in strings: Write the value in parentheses, and write a backslash () before the parentheses. For example: こちらの例とは違い複数行の文字の中の文字列の中に数値を組み込む例です。

Create arrays and dictionaries using brackets ([]), and access their elements by writing the index or key in brackets. A comma is allowed after the last element.

角括弧([])を使用して配列と辞書を作成し、それらの要素にアクセスするには、インデックスまたはキーを角括弧で囲みます。最後の要素の後にコンマを入れることができます。
var shoppingList = ["catfish", "water", "tulips", "blue paint"]
shoppingList[1] = "bottle of water"
 
var occupations = [
    "Malcolm": "Captain",
    "Kaylee": "Mechanic",
]
occupations["Jayne"] = "Public Relations"

print(shoppingList)
print(occupations)
print(occupations["Malcolm"])

上記のように入力し実行すれば下記になります

/swift-execution/Sources/main.swift:12:7: warning: expression implicitly coerced from 'String?' to Any
print(occupations["Malcolm"])
      ^~~~~~~~~~~~~~~~~~~~~~
/swift-execution/Sources/main.swift:12:18: note: provide a default value to avoid this warning
print(occupations["Malcolm"])
      ~~~~~~~~~~~^~~~~~~~~~~
                             ?? <#default value#>
/swift-execution/Sources/main.swift:12:18: note: force-unwrap the value to avoid this warning
print(occupations["Malcolm"])
      ~~~~~~~~~~~^~~~~~~~~~~
                            !
/swift-execution/Sources/main.swift:12:18: note: explicitly cast to Any with 'as Any' to silence this warning
print(occupations["Malcolm"])
      ~~~~~~~~~~~^~~~~~~~~~~
                             as Any
Linking ./.build/x86_64-unknown-linux/debug/TempCode
["catfish", "bottle of water", "tulips", "blue paint"]
["Kaylee": "Mechanic", "Jayne": "Public Relations", "Malcolm": "Captain"]
Optional("Captain")
To create an empty array or dictionary, use the initializer syntax.

空の配列または辞書を作成するには、イニシャライザ構文を使用します。
let emptyArray = [String]()
let emptyDictionary = [String: Float]()
print(emptyArray)
print(emptyDictionary)

上記のように入力し実行すれば下記になります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
[]
[:]
If type information can be inferred, you can write an empty array as [] and an empty dictionary as [:]—for example, when you set a new value for a variable or pass an argument to a function.

型情報が推測できる場合は、空の配列を[]、空の辞書を[:]と書くことができます。たとえば、変数に新しい値を設定したり、関数に引数を渡したりします。
var shoppingList = ["catfish", "water", "tulips", "blue paint"]
shoppingList[1] = "bottle of water"
 
var occupations = [
    "Malcolm": "Captain",
    "Kaylee": "Mechanic",
]
occupations["Jayne"] = "Public Relations"
shoppingList =  []
 occupations = [:]

print( shoppingList)
print(occupations)

上記のように入力し実行すれば下記になります

Linking ./.build/x86_64-unknown-linux/debug/TempCode
[]
[:]

長くなりそうなのでPageごとに書きます

PHP7でLaravelの開発環境を構築する-Part1

今回は、C9で PHP をバージョンアップしてLaravelをcomposerで管理を
行ったときのメモです。

Part1ではPHPをPHP7以上にバージョンアップするところまで行います。

*開発環境*
・cloud9
・PHP7
・Laravel5.2

$ sudo apt-get update

sudo apt-get update
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
Ign http://downloads-distro.mongodb.org dist InRelease                         
Get:2 http://ppa.launchpad.net trusty InRelease [15.5 kB]                      
Hit http://downloads-distro.mongodb.org dist Release.gpg                       
Ign http://asia-east1.gce.clouds.archive.ubuntu.com trusty InRelease           
Get:3 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:4 http://ppa.launchpad.net trusty InRelease [15.4 kB]    
Ign http://toolbelt.heroku.com ./ InRelease                                    
Get:5 http://security.ubuntu.com trusty-security/main Sources [167 kB]         
Hit http://downloads-distro.mongodb.org dist Release                           
Get:6 http://ppa.launchpad.net trusty/main amd64 Packages [23.2 kB]            
Get:7 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports InRelease [65.9 kB]
Hit http://toolbelt.heroku.com ./ Release.gpg                                  
Get:8 http://asia-east1.gce.clouds.archive.ubuntu.com trusty Release.gpg [933 B]
Hit http://downloads-distro.mongodb.org dist/10gen amd64 Packages              
Get:9 http://security.ubuntu.com trusty-security/universe Sources [62.7 kB]    
Get:10 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main Sources [492 kB]
Hit http://toolbelt.heroku.com ./ Release                                      
Get:11 http://ppa.launchpad.net trusty/main i386 Packages [23.2 kB]            
Get:12 http://security.ubuntu.com trusty-security/main amd64 Packages [767 kB] 
Hit http://downloads-distro.mongodb.org dist/10gen i386 Packages               
Get:13 http://ppa.launchpad.net trusty/main amd64 Packages [3427 B]            
Hit http://toolbelt.heroku.com ./ Packages                                     
Get:14 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted Sources [6467 B]
Get:15 http://ppa.launchpad.net trusty/main i386 Packages [3427 B]             
Get:16 http://security.ubuntu.com trusty-security/universe amd64 Packages [203 kB]
Get:17 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe Sources [226 kB]
Get:18 http://security.ubuntu.com trusty-security/main i386 Packages [710 kB]
Get:19 http://security.ubuntu.com trusty-security/universe i386 Packages [203 kB]
Get:20 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse Sources [7656 B]
Get:21 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [1233 kB]
Get:22 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted amd64 Packages [21.2 kB]
Get:23 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [524 kB]
Get:24 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [15.6 kB]
Get:25 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main i386 Packages [1174 kB]
Get:26 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted i386 Packages [20.9 kB]
Get:27 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe i386 Packages [526 kB]
Get:28 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse i386 Packages [16.1 kB]
Get:29 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main Sources [10.4 kB]
Get:30 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted Sources [40 B]
Get:31 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe Sources [41.2 kB]
Get:32 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse Sources [1751 B]
Get:33 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main amd64 Packages [14.8 kB]
Get:34 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted amd64 Packages [40 B]
Get:35 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe amd64 Packages [52.6 kB]
Get:36 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse amd64 Packages [1396 B]
Get:37 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main i386 Packages [14.8 kB]
Get:38 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted i386 Packages [40 B]
Get:39 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe i386 Packages [52.6 kB]
Get:40 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse i386 Packages [1381 B]
Get:41 http://asia-east1.gce.clouds.archive.ubuntu.com trusty Release [58.5 kB]
Get:42 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main Sources [1335 kB]
Get:43 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted Sources [5335 B]
Get:44 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe Sources [7926 kB]
Get:45 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse Sources [211 kB]
Get:46 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main amd64 Packages [1743 kB]
Get:47 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted amd64 Packages [16.0 kB]
Get:48 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe amd64 Packages [7589 kB]
Get:49 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse amd64 Packages [169 kB]
Get:50 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main i386 Packages [1739 kB]
Get:51 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted i386 Packages [16.4 kB]
Get:52 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe i386 Packages [7597 kB]
Get:53 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse i386 Packages [172 kB]
Fetched 35.4 MB in 18s (1892 kB/s)                                             
Reading package lists... Done
W: Size of file /var/lib/apt/lists/ppa.launchpad.net_fkrull_deadsnakes_ubuntu_dists_trusty_main_binary-amd64_Packages.gz is not what the server reported 23171 23198
W: Size of file /var/lib/apt/lists/ppa.launchpad.net_fkrull_deadsnakes_ubuntu_dists_trusty_main_binary-i386_Packages.gz is not what the server reported 23183 23195

$sudo add-apt-repository ppa:ondrej/php

sg_tmt:~/workspace $ sudo add-apt-repository ppa:ondrej/php
Co-installable PHP versions: PHP 5.6, PHP 7.0, PHP 7.1 and most requested extensions are included.

PLEASE DON'T USE PHP 5.4 OR PHP 5.5. The PHP 5.5 and later are no longer supported with security updates, therefore they are not included in this repository.

You can get more information about the packages at https://deb.sury.org

BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmptrdsipzz/secring.gpg' created
gpg: keyring `/tmp/tmptrdsipzz/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmptrdsipzz/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

$sudo apt-get install python-software-properties

sg_tmt:~/workspace $ sudo apt-get install python-software-properties
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
 python-pycurl
Suggested packages:
 libcurl4-gnutls-dev python-pycurl-dbg
The following NEW packages will be installed:
 python-pycurl python-software-properties
0 upgraded, 2 newly installed, 0 to remove and 93 not upgraded.
Need to get 67.5 kB of archives.
After this operation, 358 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://asia-east1.gce.clouds.archive.ubuntu.com/ubuntu/ trusty/main python-pycurl amd64 7.19.3-0ubuntu3 [47.9 kB]
Get:2 http://asia-east1.gce.clouds.archive.ubuntu.com/ubuntu/ trusty-updates/universe python-software-properties all 0.92.37.7 [19.6 kB]
Fetched 67.5 kB in 1s (52.9 kB/s)                     
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Selecting previously unselected package python-pycurl.
(Reading database ... 75437 files and directories currently installed.)
Preparing to unpack .../python-pycurl_7.19.3-0ubuntu3_amd64.deb ...
Unpacking python-pycurl (7.19.3-0ubuntu3) ...
Selecting previously unselected package python-software-properties.
Preparing to unpack .../python-software-properties_0.92.37.7_all.deb ...
Unpacking python-software-properties (0.92.37.7) ...
Setting up python-pycurl (7.19.3-0ubuntu3) ...
Setting up python-software-properties (0.92.37.7) ...

$sudo apt-get update

sg_tmt:~/workspace $ sudo apt-get update
Hit http://security.ubuntu.com trusty-security InRelease
Hit http://ppa.launchpad.net trusty InRelease                                  
Ign http://downloads-distro.mongodb.org dist InRelease                         
Ign http://asia-east1.gce.clouds.archive.ubuntu.com trusty InRelease           
Hit http://ppa.launchpad.net trusty InRelease 
Get:1 http://ppa.launchpad.net trusty InRelease [20.9 kB]                      
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates InRelease   
Hit http://security.ubuntu.com trusty-security/main Sources                    
Ign http://toolbelt.heroku.com ./ InRelease                                    
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports InRelease 
Hit http://downloads-distro.mongodb.org dist Release.gpg                       
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty Release.gpg         
Hit http://security.ubuntu.com trusty-security/universe Sources                
Hit http://ppa.launchpad.net trusty/main amd64 Packages                        
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty Release             
Hit http://security.ubuntu.com trusty-security/main amd64 Packages             
Hit http://downloads-distro.mongodb.org dist Release                           
Hit http://ppa.launchpad.net trusty/main i386 Packages                         
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main Sources
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages         
Hit http://security.ubuntu.com trusty-security/main i386 Packages              
Hit http://ppa.launchpad.net trusty/main amd64 Packages                        
Hit http://toolbelt.heroku.com ./ Release.gpg                                  
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted Sources
Hit http://security.ubuntu.com trusty-security/universe i386 Packages          
Hit http://ppa.launchpad.net trusty/main i386 Packages                         
Hit http://downloads-distro.mongodb.org dist/10gen amd64 Packages              
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe Sources
Get:2 http://ppa.launchpad.net trusty/main amd64 Packages [53.3 kB]            
Hit http://toolbelt.heroku.com ./ Release                                      
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse Sources
Hit http://downloads-distro.mongodb.org dist/10gen i386 Packages               
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://toolbelt.heroku.com ./ Packages                                     
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted amd64 Packages
Get:3 http://ppa.launchpad.net trusty/main i386 Packages [53.4 kB]
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main Sources
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted Sources
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe Sources
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse Sources
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main Sources        
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted Sources  
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe Sources    
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse Sources  
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main amd64 Packages 
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse amd64 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main i386 Packages  
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe i386 Packages
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse i386 Packages
Fetched 128 kB in 11s (10.7 kB/s)                                              
Reading package lists... Done

$sudo apt-get install php

sg_tmt:~/workspace $ sudo apt-get install php
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libapache2-mod-php7.1 libssl1.0.2 php-common php7.1 php7.1-cli php7.1-common
  php7.1-json php7.1-opcache php7.1-readline
The following NEW packages will be installed:
  libapache2-mod-php7.1 libssl1.0.2 php php-common php7.1 php7.1-cli
  php7.1-common php7.1-json php7.1-opcache php7.1-readline
0 upgraded, 10 newly installed, 0 to remove and 105 not upgraded.
Need to get 4928 kB of archives.
After this operation, 18.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main libssl1.0.2 amd64 1.0.2k-1+deb.sury.org~trusty+5 [1270 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php-common all 1:52+deb.sury.org~trusty+1 [14.3 kB]
Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.1-common amd64 7.1.5-1+deb.sury.org~trusty+1 [877 kB]
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.1-json amd64 7.1.5-1+deb.sury.org~trusty+1 [17.4 kB]
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.1-opcache amd64 7.1.5-1+deb.sury.org~trusty+1 [140 kB]
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.1-readline amd64 7.1.5-1+deb.sury.org~trusty+1 [12.2 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.1-cli amd64 7.1.5-1+deb.sury.org~trusty+1 [1300 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main libapache2-mod-php7.1 amd64 7.1.5-1+deb.sury.org~trusty+1 [1242 kB]
Get:9 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.1 all 7.1.5-1+deb.sury.org~trusty+1 [50.1 kB]
Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php all 1:7.1+52+deb.sury.org~trusty+1 [5200 B]
Fetched 4928 kB in 12s (386 kB/s)                                              
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Preconfiguring packages ...
Selecting previously unselected package libssl1.0.2:amd64.
(Reading database ... 75480 files and directories currently installed.)
Preparing to unpack .../libssl1.0.2_1.0.2k-1+deb.sury.org~trusty+5_amd64.deb ...
Unpacking libssl1.0.2:amd64 (1.0.2k-1+deb.sury.org~trusty+5) ...
Selecting previously unselected package php-common.
Preparing to unpack .../php-common_1%3a52+deb.sury.org~trusty+1_all.deb ...
Unpacking php-common (1:52+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.1-common.
Preparing to unpack .../php7.1-common_7.1.5-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.1-common (7.1.5-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.1-json.
Preparing to unpack .../php7.1-json_7.1.5-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.1-json (7.1.5-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.1-opcache.
Preparing to unpack .../php7.1-opcache_7.1.5-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.1-opcache (7.1.5-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.1-readline.
Preparing to unpack .../php7.1-readline_7.1.5-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.1-readline (7.1.5-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.1-cli.
Preparing to unpack .../php7.1-cli_7.1.5-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.1-cli (7.1.5-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package libapache2-mod-php7.1.
Preparing to unpack .../libapache2-mod-php7.1_7.1.5-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking libapache2-mod-php7.1 (7.1.5-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.1.
Preparing to unpack .../php7.1_7.1.5-1+deb.sury.org~trusty+1_all.deb ...
Unpacking php7.1 (7.1.5-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php.
Preparing to unpack .../php_1%3a7.1+52+deb.sury.org~trusty+1_all.deb ...
Unpacking php (1:7.1+52+deb.sury.org~trusty+1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libssl1.0.2:amd64 (1.0.2k-1+deb.sury.org~trusty+5) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Setting up php-common (1:52+deb.sury.org~trusty+1) ...
Setting up php7.1-common (7.1.5-1+deb.sury.org~trusty+1) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/calendar.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/ctype.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/exif.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/fileinfo.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/ftp.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/gettext.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/iconv.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/pdo.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/phar.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/posix.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/shmop.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/sockets.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/sysvmsg.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/sysvsem.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/sysvshm.ini with new version
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/tokenizer.ini with new version
Setting up php7.1-json (7.1.5-1+deb.sury.org~trusty+1) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/json.ini with new version
Setting up php7.1-opcache (7.1.5-1+deb.sury.org~trusty+1) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/opcache.ini with new version
Setting up php7.1-readline (7.1.5-1+deb.sury.org~trusty+1) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/mods-available/readline.ini with new version
Setting up php7.1-cli (7.1.5-1+deb.sury.org~trusty+1) ...
update-alternatives: using /usr/bin/php7.1 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.1 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.1 to provide /usr/bin/phar.phar (phar.phar) in auto mode
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/cli/php.ini with new version
Setting up libapache2-mod-php7.1 (7.1.5-1+deb.sury.org~trusty+1) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline

Creating config file /etc/php/7.1/apache2/php.ini with new version
libapache2-mod-php7.1: php5 module already enabled, not enabling PHP 7.1
Setting up php7.1 (7.1.5-1+deb.sury.org~trusty+1) ...
Setting up php (1:7.1+52+deb.sury.org~trusty+1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...

$php -v

sg_tmt:~/workspace $ php -v
PHP 7.1.5-1+deb.sury.org~trusty+1 (cli) (built: May 11 2017 14:36:07) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.5-1+deb.sury.org~trusty+1, Copyright (c) 1999-2017, by Zend Technologies

これでPHPがPHP7以上にupdate完了

2016年も終わりだし自分のモバイル開発について振り返ってみる

はじめに

※一個人としての感想なので組織などの思惑とは関係ありません ※一個人のポエムです。 年末なので自分のモバイル開発について振り返ってみる

もともと

Android+Objective-Cを専門学校で学んでいた ー暇な時に自分で何か作ったりはしていたけど人に見せる方ではなかった

・卒業後Sierに入社して社内でObjective-Cを教えてもらったけど  むしろ嫌いになった  

Swift

Objective-Cとくらべてソースが少なかった  ーObjCにあまり良い印象も持っていなかったけど好きになった

勉強会

Swift愛好会

経緯 ・~.apkみたいにAndroidだと個人が勉強を開いたりJAGが勉強会を主催したり はあるけどiOSの勉強会は少なかった(あっても上級者向け)

iOS関連の知見を深めたかった

参加した結果 ・iOSの知見が高められた ・同じ技術に興味ある知人が増えた ・何かアウトプットしろっていってくる人種が湧いた? ・ReproSDKについて関心を持った

free-Styleもくもく会

言語未指定もくもく会 同じ言語をやってる人以外もいるので知らない人に伝える アウトプットの練習になる  

まとめ

・Swiftはいいぞ ・Swift愛好会は優しい ・アウトプットは大事

MVPとMVCとかMVVMとかを振り返るその1

はじめに

MVPとMVCとかMVVMとかの違いについてそこまで詳しく理解できていない 

ほぼMVCで開発する場合が多いけど設計について理解してないので
MVPとMVCとかMVVMとかの違いについて振り返る。

Model-View-Controller

Model

・データ保持
ビジネスロジック

View

・LayoutXML
・View
・ViewGroup

Controller

・Fragment
・Activity
・Viewの表示や作成を担当する

MVCの目的は何をどう見せたいか?ということをプログラミングの力で実現することだと思うのでMVC設計のコンセプトを取り入れることによって
なにを実現したいか?ということについては表現出来ると思います。

ただどう見せたいかはこの設計をすれば「こう見せたい」という表現が出来るわけではないので模索することが必要です。

その2ではMVPについて振り返ります。