Pebble Coding

ソフトウェアエンジニアによるIT技術、数学の備忘録

2015-04-01から1ヶ月間の記事一覧

NSString型のプロパティ

Objective-CでNSString型のプロパティににはstrong属性ではなく、copy属性を使った方がよいという記事をみかけますが、 私はデフォルトのstrongのまま使います。 copy属性を使った方がよい理由として、NSMutableStringの値を設定したときに、copy属性の方が…

OpenSSL::SSL::SSLError

railsアプリがなんか次のような500エラーを吐くようになった。 OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read finished A: unexpected message) 外部のサーバにhttpsでアクセスしているところで出ているっぽい。 サーバのnginx.…

rails redirect_to model

redirect_to modelの形がよく出てくるけど、いまいちドキュメントに例が載ってなくて分からない。StackOverFlowに回答が載っていた。 what does redirect_to(@model) means in rails? - Stack Overflow @userがUserモデルのid=1のインスタンス変数の場合 red…

ruby文法その4

演算子の優先順位 (高) ! ~ ** * / % + - << >> & | ^ > >= < <= == != && || .. ... ?: = not and or (低) <と&&では<のほうが優先順位が高い。なので次の結果は納得できるだろう。 irb(main):001:0> num = 1 < 2 && 5 5 irb(main):001:0> num = 1 > 2 && 5…

ruby文法その3

前回のソースコードをもう少し見ていきます。 少し変更して次のようにしてみるとどうなるでしょうか? # MyMathModule.rb module MyMathModule def plus(x, y) x + y + (@something || 0) end end # MyApp.rb require './MyMathModule' class MyApp include …

ruby文法その2

Moduleの使い方。 ディレクトリにMyMathModule.rbとMyApp.rbの2つのファイルを作成してみる。 # MyMathModule.rb module MyMathModule def plus(x, y) x + y end end # MyApp.rb require "./MyMathModule" class MyApp include MyMathModule end myapp = My…