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
3.5k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
70
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
0
1.6k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
470
26新卒_総合職採用_会社説明資料
livesense
PRO
0
12k
株式会社リブセンス会社紹介資料 / Invent the next common.
livesense
PRO
1
41k
26新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
1
13k
中途セールス職_会社説明資料
livesense
PRO
0
270
EM候補者向け転職会議説明資料
livesense
PRO
0
130
Other Decks in Technology
See All in Technology
Performance Insights 廃止から Database Insights 利用へ/transition-from-performance-insights-to-database-insights
emiki
0
300
Data Hubグループ 紹介資料
sansan33
PRO
0
2.2k
2025-10-09_プロジェクトマネージャーAIチャンス
taukami
0
150
RDS の負荷が高い場合に AWS で取りうる具体策 N 連発/a-series-of-specific-countermeasures-available-on-aws-when-rds-is-under-high-load
emiki
4
3.5k
Findy Team+ QAチーム これからのチャレンジ!
findy_eventslides
0
410
アイテムレビュー機能導入からの学びと改善
zozotech
PRO
0
180
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
12
80k
dbtとBigQuery MLで実現する リクルートの営業支援基盤のモデル開発と保守運用
recruitengineers
PRO
3
100
いまからでも遅くない!SSL/TLS証明書超入門(It's not too late to start! SSL/TLS Certificates: The Absolute Beginner's Guide)
norimuraz
0
260
Codexとも仲良く。CodeRabbit CLIの紹介
moongift
PRO
1
240
フレームワークを意識させないワークショップづくり
keigosuda
0
200
20251010_HCCJP_AdaptiveCloudUpdates
sdosamut
0
140
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
173
14k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
What's in a price? How to price your products and services
michaelherold
246
12k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
Mobile First: as difficult as doing things right
swwweet
225
10k
Why Our Code Smells
bkeepers
PRO
340
57k
Balancing Empowerment & Direction
lara
5
690
Unsuck your backbone
ammeep
671
58k
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