Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

java switch

Name: Anonymous 2011-10-20 11:32

Why does java not allow String objects to be used in the switch/case statements? Couldn't the compile invoke hashcode() on those strings thus producing a unique integer value to represent the constant in the cases?

Name: Anonymous 2011-10-21 13:59

>>28
The problem here is that your example isn't good. In it, there's not actually any variable functionality, just variable strings. This is obvious in the Lua example where all the functions are anonymous and follow a common pattern. For instance, you could implement the lua thing with:


local printy =
{
  Lua = merki,
  Is = derpity,
  Fun = dipity,
  ["Is it Not?"] = "dooooo"
}

function woop(value)
  print(
    (printy[value] or "Go have fun with yourself.")
    .." "..value)
end


because there's no variation on the fact that the thing is printing and concatenating.

Remember, what you want to do is describe -out- patterns, not describe -in- patterns.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List