Upgrade to Pro — share decks privately, control downloads, hide ads and more …

NULLに関する一考察 #TechLunch

NULLに関する一考察 #TechLunch

2011/10/05(水) @ Livesense TechLunch
発表者:桂 大介

Livesense Inc.

April 23, 2014
Tweet

More Decks by Livesense Inc.

Other Decks in Technology

Transcript

  1. 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
  2. Perl 6 my $value $value // Any() $value = Nil

    $value // Any() $value.defined // Bool::False
  3. Javascript value; // undefined typeof value === 'undefined' // true

    value === void 0 // true value = void 0; value = null value === null // true
  4. Haskell Maybe v1 = Just 1 v2 = Nothing getValueOrTwo

    v = case v of Just x -> x Nothing -> 2 getValueOrTwo v1 // 1 getValueOrTwo v2 // 2
  5. 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
  6. 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 = {};
  7. 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