ifMaybe :: Maybe a -> (a -> IO ()) -> IO ()
ifMaybe = flip $ maybe (return ())
2d_map = [('some_key', [('second_key', "hello world")])]
main = do
let item = (lookup "second_key" <=< lookup "some_key") $ 2d_map
ifMaybe item $ \it -> do
print it
– could shorten lines 6 and 7 to this, since it is such a short block:
– ifMaybe item print
public HashMap<String, HashMap <String, String>> myMap = new HashMap() { put("firstkey", new HashMap() { put("secondKey", "test"}};
if exp
print it
var = exp
if exp
print var
if (a = b and c = d)
print it
if (a = b and c = d)
print it
> (println (if 1 "foo"))
foo
nil
>
> (if-let [it 1] (println it))
1
nil
>
if (bla)
if (bli)
print it
if (bla)
if (bli)
print it
if (bla)
print $_;
In this example, it is a keyword that represents the value of the if statement. Anyone know a language do this without requiring setting a variable yourself?