Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
NULLに関する一考察 #TechLunch
Search
Livesense Inc.
PRO
April 23, 2014
Technology
0
59
NULLに関する一考察 #TechLunch
2011/10/05(水) @ Livesense TechLunch
発表者:桂 大介
Livesense Inc.
PRO
April 23, 2014
Tweet
Share
More Decks by Livesense Inc.
See All by Livesense Inc.
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
2.4k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
51
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
0
1.5k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
440
26新卒_総合職採用_会社説明資料
livesense
PRO
0
11k
株式会社リブセンス会社紹介資料 / Invent the next common.
livesense
PRO
1
37k
26新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
1
13k
中途セールス職_会社説明資料
livesense
PRO
0
260
EM候補者向け転職会議説明資料
livesense
PRO
0
130
Other Decks in Technology
See All in Technology
Language Update: Java
skrb
2
290
Codeful Serverless / 一人運用でもやり抜く力
_kensh
7
360
RSCの時代にReactとフレームワークの境界を探る
uhyo
10
3.3k
生成AIでセキュリティ運用を効率化する話
sakaitakeshi
0
450
実践!カスタムインストラクション&スラッシュコマンド
puku0x
0
320
Webブラウザ向け動画配信プレイヤーの 大規模リプレイスから得た知見と学び
yud0uhu
0
230
未経験者・初心者に贈る!40分でわかるAndroidアプリ開発の今と大事なポイント
operando
3
300
[ JAWS-UG 東京 CommunityBuilders Night #2 ]SlackとAmazon Q Developerで 運用効率化を模索する
sh_fk2
3
370
Aurora DSQLはサーバーレスアーキテクチャの常識を変えるのか
iwatatomoya
0
280
AIのグローバルトレンド2025 #scrummikawa / global ai trend
kyonmm
PRO
1
260
Agile PBL at New Grads Trainings
kawaguti
PRO
1
380
シークレット管理だけじゃない!HashiCorp Vault でデータ暗号化をしよう / Beyond Secret Management! Let's Encrypt Data with HashiCorp Vault
nnstt1
3
230
Featured
See All Featured
Navigating Team Friction
lara
189
15k
Thoughts on Productivity
jonyablonski
70
4.8k
Embracing the Ebb and Flow
colly
87
4.8k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Faster Mobile Websites
deanohume
309
31k
The Cult of Friendly URLs
andyhume
79
6.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
187
55k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Transcript
NULL に関する ー 考 察
[email protected]
NULL に関する ー 考 察
[email protected]
/nʌl/
nullus
From ne (“not”) + ūllus (“any”), literally meaning "not any".
Differences in dealing with null
null = undefined
PHP $value // null isset($value) // false is_null($value) // true
$value === null // true unset($value) $value = null $hash = array('key' => null) array_key_exists('key', $hash) // true isset($hash['key']) // false
Perl 5 $value // undef defined $value // false undef
$value
Perl 6 my $value $value // Any() $value = Nil
$value // Any() $value.defined // Bool::False
null and undefined
Javascript value; // undefined typeof value === 'undefined' // true
value === void 0 // true value = void 0; value = null value === null // true
null only
Ruby value // NameError defined? value // nil(false?) undef value
value = nil value.nil? // true
Python value // NameError del value value = None value
is None // true
wrapped null
Scala Option v1 = Some(1) v2 = None v1.getOrElse(2) //
1 v2.getOrElse(2) // 2
Haskell Maybe v1 = Just 1 v2 = Nothing getValueOrTwo
v = case v of Just x -> x Nothing -> 2 getValueOrTwo v1 // 1 getValueOrTwo v2 // 2
int main() { for(int j=-5; j<=5; ++j) { optional<int> x
= sqrt(j); if( x ) cout << *x << endl; else cout << "invalid" << endl; } } boost::optional
boxing
C# nullable int? value = null value.HasValue // false Nullable.GetValueOrDefault(value,
123) // 123 Value ?? 123 // 123
making null
C++ nullptr const class nullptr_t { public: template<class T> operator
T*() const { return 0; } template<class C, class T> operator T C::*() const { return 0; } private: void operator&() const; } nullptr = {};
One more thing
void f( tribool b ) { if( b ) cout
<< "True" << endl; else if( !b ) cout << "False" << endl; else cout << "Indeterminate" << endl; } int main() { tribool x = indeterminate; f(x); // Indeterminate f(true && x); // Indeterminate f(true || x); // True } boost::logic::tribool
考察 • null は必要だけど null チェック地獄 • null と値でインターフェースを合わせるのが時 代の流れ
• →Option, nullable • →coffee script • →presence • →null object pattern
次回予告
None