• Mr Keith (unregistered)

    Susan Ivanova: Ambassador, do you really want to know what's going on down there right now? Londo Mollari: Yes, absolutely. Ivanova: Boom. Boom, boom, boom. Boom, boom. BOOM! Have a nice day.

  • shepd (unregistered)

    Gary. Gary! Gary gary, gary. HAHAHAHA GARY! Gaaaarrryyyy! No. Gary???

    Also, 101 + 7 = 108.

    You either played it, or you didn't.

  • XXXXXX (unregistered)

    I see the problem var srcDatum = datum; if (datum.datum && datum.datum.datum) { datum = datum.datum.datum; } else if (datum.datum) { datum = datum.datum; }

    if (!datum) { return; }

  • (cs) in reply to Uncle Code Monkey
    Uncle Code Monkey:
    I used to have a colleague that did something similar... but using single letter vars.

    if (a.a)...

    while (i<x.x.x)...

    and so on.

    "Used to have"... I hope that means that you killed him.

  • (cs)

    Malkovich. Malkovich malkovich malkovich, malkovich malkovich.

    Malkovich? Malkovich.

  • Glenn Lasher (unregistered) in reply to Mohonri

    How about recursively?

    data (data data)
    {
        if (data){
            return data(data.data);
        }
        else{
            return data;
        }
    }
    
  • honnza (unregistered)

    In javascript (and many other normal programming languages), you can go data = (data.data && data.data.data) || data.data || data; or even [0,0].foreach(function(){data=data.data||data})

  • (cs)

    Nobody does WTF like MS...

    this.Form.Form.Form.Form.Form.Form.Close();

  • (cs) in reply to Deezil

    http://isotropic.org/papers/chicken.pdf

  • (cs)
    commit asdfghjklpoiuytrew123456789
    Author: Paula
    
    Change code in data.js
    
    diff --git a/data.js b/data.js
    index 3cb747f..da65585 100644
    --- a/data.js
    +++ b/data.js
    
    -var srcData = data;
    -if (data.data && data.data.data) {
    -    data = data.data.data;
    -} else if (data.data) {
    -    data = data.data;
    -}
    - 
    -if (!data) {
    -    return;
    -}
    +var srcData = data1;
    +if (data1.data2 && data1.data2.data3) {
    +    data1 = data1.data2.data3;
    +} else if (data1.data2) {
    +    data1 = data1.data2;
    +}
    + 
    +if (!data1) {
    +    return;
    +}
  • (cs)

    Data? Not Data!

    [image]

    Also fuck you Akismet. Fuck you sideways with a chainsaw.

  • dkallen (unregistered) in reply to Jan
    Jan:
    > But, but, but.... isn't all data considered to be data? > What an appropriate and consistent naming convention!

    We use that too. And all the stuff that isn't data we just call 'stuff'.

    Did you ever notice everyone else's data is just stuff, but your stuff is DATA... ?

  • dkallen (unregistered) in reply to Zylon
    Zylon:
    Data? Not Data!

    [image]

    Also data you Akismet. Data you sideways with a chainsaw.

    FTFY

  • Malkovich (unregistered)

    Malkovich Malkovich Malkovich. Malkovich.

  • Maybe a Smurfs did it? (unregistered)

    Smurf smurf = smurf Smurf(smurf); smurf

  • (cs) in reply to dkallen
    dkallen:
    Did you ever notice everyone else's data is just stuff, but *your* stuff is DATA... ?
    A server is just a pile of data with a cover on it.
  • The code is broken (unregistered)

    Checking for !Data after calling properties on it (data.data)? THAT is where you are asking for trouble. Everything else seems perfectly fine :)

  • neminem (unregistered) in reply to DCRoss
    DCRoss:
    Malkovich. Malkovich malkovich malkovich, malkovich malkovich.

    Malkovich? Malkovich.

    Pika? Pikapika! Pika. Pikapikpika. Pika pikachu!

  • (cs) in reply to bluemoon
    bluemoon:
    Remy Porter:
    The "&&" makes it more unclear. Try this:
    return data ? data.data ? data.data.data ? data.data.data : data.data : data : nil
    

    That's way more concise.

    In dotnet 3.5 we have the ?? operator for this

    return data.data.data ?? data.data ?? data ?? null;

    Wouldn't that be: return data.data.data ?? data.data ?? data;

    The last part, "?? null;", is not needed since if data is null, it will be returned anyways, if it's the last part of the statement? :)

  • Your Name (unregistered)

    var srcBruce = bruce; if (bruce.bruce&& bruce.bruce.bruce) { bruce= bruce.bruce.bruce; } else if (bruce.bruce) { bruce = bruce.bruce; }

    if (!bruce) { return; }

    FTFY

  • Nemo (unregistered) in reply to Your Name
    Your Name:
    var srcMine = mine; if (mine.mine&& mine.mine.mine) { mine= mine.mine.mine; } else if (mine.mine) { mine = mine.mine; }

    if (!mine) { return; }

    FTFY

    FTFTFY

  • MS Game Programmer (unregistered) in reply to Nemo
    Nemo:
    Your Name:
    var srcMine = mine; int mine(int xmine, int ymine) { if (mines(xmine, ymine)) { return -1; } else { return -mine(xmine - 1, ymine) -mine(xmine -1, ymine -1) -mine(xmine -1, ymine + 1) -mine(xmine, ymine +1) -mine(xmine, ymine -1) -mine(xmine - 1, ymine) -mine(xmine, ymine + 1) -mine(xmine +1, ymine + 1); } FTFY
    FTFTFY
  • danbruc (unregistered) in reply to Mythran
    Mythran:
    bluemoon:
    Remy Porter:
    The "&&" makes it more unclear. Try this:
    return data ? data.data ? data.data.data ? data.data.data : data.data : data : nil
    

    That's way more concise.

    In dotnet 3.5 we have the ?? operator for this

    return data.data.data ?? data.data ?? data ?? null;

    Wouldn't that be: return data.data.data ?? data.data ?? data;

    The last part, "?? null;", is not needed since if data is null, it will be returned anyways, if it's the last part of the statement? :)

    data.data.data ?? data.data ?? data [?? null] does not work - it will just throw a NullReferenceException unless all three levels are non-null. Also the article contains only a single return statement returning nothing - no one knows what happens to data.

  • danbruc (unregistered) in reply to danbruc
    danbruc:
    Mythran:
    bluemoon:
    Remy Porter:
    The "&&" makes it more unclear. Try this:
    return data ? data.data ? data.data.data ? data.data.data : data.data : data : nil
    

    That's way more concise.

    In dotnet 3.5 we have the ?? operator for this

    return data.data.data ?? data.data ?? data ?? null;

    Wouldn't that be: return data.data.data ?? data.data ?? data;

    The last part, "?? null;", is not needed since if data is null, it will be returned anyways, if it's the last part of the statement? :)

    data.data.data ?? data.data ?? data [?? null] does not work - it will just throw a NullReferenceException unless all three levels are non-null. Also the article contains only a single return statement returning nothing - no one knows what happens to data.

    Obviously it should read "[...] unless the first two levels [...]".

  • chernobyl (unregistered)

    Developers, developers, developers, developers!

  • DMJ (unregistered)

    Ok, I admit I wrote it, but in my defense, I was stoned.

  • vereor (unregistered)

    Reminds me of planet Marklar.

    http://en.wikipedia.org/wiki/Starvin%27_Marvin_in_Space

  • vereor (unregistered) in reply to garden
    garden:
    http://isotropic.org/papers/chicken.pdf

    This was funny. But, tell us, how did you find this, know about this, etc? Was this a mistake, something intentional - what's the point?

  • Tom (unregistered)

    Haven't you all heard of data driven development? WTF?

  • (cs)

    Kyle: “Marklar, these marklars want to change your marklar. They don't want Marklar or any of these marklars to live here because it's bad for their marklar. They use Marklar to try and force marklars to believe they're marklar. If you let them stay here, they will build marklars and marklars. They will take all your marklars and replace them with Marklar. These marklar have no good marklar to live on Marklar, so they must come here to Marklar. Please, let these marklars stay where they can grow and prosper without any marklars, marklars, or marklars.”

    Alien: "Young Marklar, your Marklars are wise and true."

  • Gunslinger (unregistered)

    Where's the xkcd reference?

  • vereor (unregistered) in reply to Zylon
    Zylon:
    Data? Not Data!

    [image]

    Also fuck you Akismet. Fuck you sideways with a chainsaw.

    Shhh = you should use the word "frak". There's a fuck in here that will fuck your fuck if you keep using the word "fuck".

  • Batman (unregistered)

    Data Data Data Data Data Data Data Data Batman!

  • Tom (unregistered)

    Malkovich?

    (Captcha: nulla. When data.data.data has no value.value.value, it's nulla.nulla.nulla.)

  • big picture thinker (unregistered) in reply to Tyler
    Tyler:
    Except that this looks like PHP, in which case using more than one ternary produces unexpected results. http://www.phpsadness.com/sad/30

    Could be an old version of PHP. That blog is undated.

    Might also have to do with the way they define TRUE and FALSE in PHP. Normally it should be:

    #define FALSE 0 #define TRUE (!FALSE)

    But this is not universal. I would suggest trying that test again with something more explicit like:

    <?php echo (1 == 2 ? "a" : 1 == 2 ? "b" : "c")."\n"; echo (1 == 2 ? "a" : 1 == 1 ? "b" : "c")."\n"; echo (1 == 1 ? "a" : 1 == 2 ? "b" : "c")."\n"; echo (1 == 1 ? "a" : 1 == 1 ? "b" : "c")."\n"; ?>

    Also, you could try using parentheses to enforce order of operation:

    <?php echo (1 == 2 ? "a" : (1 == 2 ? "b" : "c"))."\n"; echo (1 == 2 ? "a" : (1 == 1 ? "b" : "c"))."\n"; echo (1 == 1 ? "a" : (1 == 2 ? "b" : "c"))."\n"; echo (1 == 1 ? "a" : (1 == 1 ? "b" : "c"))."\n"; ?>

    I've used multiple stacked ternary expressions plenty of times in PHP with expected results.

  • Mike (unregistered)

    Data data data. I cannot make bricks without clay.

  • (cs) in reply to Gunslinger
    Gunslinger:
    Where's the xkcd reference?

    Never mind that, where's the sidebar reference?

    "data processing, data data processing"

  • Erbo (unregistered)

    Douglas "Swish" Reemer: Dude! Coop: Dude! Douglas "Swish" Reemer: Dude! Coop: Dude! Douglas "Swish" Reemer: Dude! [Coop looks shocked] Douglas "Swish" Reemer: Dude. Coop: I guess you have a point. (From the movie "BASEketball," 1998)

  • davee123 (unregistered) in reply to I am the night.
    I am the night.:
    causa:
    Joey:
    Holy hell, doesn't anyone use ternarys anymore? Gosh!
    var srcData = data;
    return data.data && data.data.data ? data.data.data : data.data ? data.data : data ? data : null;

    Batman!

    Why isn't this featured yet?

    Well, it's not quite an exact match. The code only returns things when data is false. I believe a more accurate rewrite would be:

    var srcData = data;
    data = data.data && data.data.data ? data.data.data : data.data ? data.data : null;
    if(!data) { return; }

    DaveE

  • (cs)

    This problem, like all others, could be solved by adding another level of indirection..

    Put another wrapper round it: and call it data.

  • Harrow (unregistered)

    In Delphi Pascal that would be:

    ...
    var srcData : object;
    ...
    with data do
      with data do begin
        srcData := data; 
        if data and data then 
          data := data 
        else if data then 
          data := data; 
        if not data then
          return; 
      end;
    ...

    Which, I am confident you will agree, is much more cromulent.

    -Harrow.

  • (cs) in reply to shepd
    shepd:
    Gary. Gary! Gary gary, gary. HAHAHAHA GARY! Gaaaarrryyyy! No. Gary???

    Also, 101 + 7 = 108.

    You either played it, or you didn't.

    I still have nightmares about Gary.

  • Norman Diamond (unregistered) in reply to Riccardo
    Riccardo:
    Chicken chicken, chicken? http://www.youtube.com/watch?v=yL_-1d9OSdk
    Ura niwa niwa niwa niwa niwa niwa niwa tori iru.

    There are two chickens in the back yard and two chickens in the front yard.

  • AndrewH (unregistered)

    The problem is actually with the guy who created the data.data.data object, not the poor guy who's had to perform some logic on it. Assuming they're different guys.

  • Blonde (unregistered)

    How many d's in "Rudolph the Red Nosed Reindeer"? 7 - d d, d d d d d....

  • Norman Diamond (unregistered) in reply to Norman Diamond
    Norman Diamond:
    Riccardo:
    Chicken chicken, chicken?
    Ura niwa niwa niwa niwa niwa niwa niwa tori iru.
    Sheesh, where's the English translation of this one: http://ja.wikipedia.org/wiki/%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90%E5%AD%90 <realwtf> spam ? akismet.accept() : akismet.reject(alert("akismet rejects non-spam")); </realwtf>
  • Git's Hubby (unregistered)

    Sounds like a Haiku a friend of mine once wrote:

    git git git git git git git git git git git git git git git git git

  • (cs) in reply to Deezil
    Deezil:
    http://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo

    Hmmm so what about a buffalo called "Buffalo"?

    I'm going to add one: "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo Buffalo"

    (Modified quote from Wikipedia: -) THE buffalo FROM Buffalo WHO ARE buffaloED BY buffalo FROM Buffalo, buffalo (verb) OTHER buffalo FROM Buffalo NAMED Buffalo.

    I guess you could even add some more in there... Though of course the real wtf would be calling a Buffalo buffalo Buffalo.

  • Topaz (unregistered) in reply to big picture thinker

    It's undated but accurate. The ternary operator in PHP has reversed associativity from any other language. Try it for yourself; you can't get any result but the last two.

  • (cs) in reply to Joey
    Joey:
    Holy hell, doesn't anyone use ternarys anymore? Gosh!
    var srcData = data;
    return data.data && data.data.data ? data.data.data : data.data ? data.data : data ? data : null;

    You know, if he'd added one more level in his structure, he could have gotten rid of that silly null. Use of case sensitivity would have helped, too:

    var Data = data;
    return data.data && data.data.data ? data.data.data : data.data ? data.data : data ? data : data.data.data.data;

Leave a comment on “Data? Data data. Data.”

Log In or post as a guest

Replying to comment #:

« Return to Article