Last Updated: October 18, 2020
·
6.423K
· anthonylevings

Wishing you a multilingual Christmas

Ruby

Christmas="beer "
NewYear="more beer"
if Christmas + NewYear=="beer more beer"
    print "festive hangover"
end

Objective-C

NSString *Christmas=@"beer ";
NSString *NewYear=@"more beer";

if ([[NSString stringWithFormat:@"%@%@",Christmas,NewYear] isEqualToString:@"beer more beer"]) NSLog(@"%@", @"festive hangover");

Python

Christmas="beer "
NewYear="more beer"
if Christmas + NewYear=="beer more beer":
    print "festive hangover"

JavaScript

var Xmas= "beer ";
var NewYear = "more beer";
if (Xmas+NewYear==="beer more beer") 
document.write("festive hangover");

PHP

$Christmas = "beer ";
$NewYear = "even more beer";
if ($Christmas.$NewYear==="beer even more beer") echo "festive hangover"; 

Please add as many new languages to the comments as you like

13 Responses
Add your response

C#:

var Christmas = "beer ";
var NewYear = "more beer";

if (Christmas + NewYear == "beer more beer")
    Console.WriteLine("festive hangover");
over 1 year ago ·

C++:

string Christmas = "beer ";
string NewYear = "more beer";
if (Christmas + NewYear == "beer more beer")
  cout << "festive hangover\n";

Haskell:

let after a b = if b ++ a == "beer more beer" then "festive hangover" else ""
let Christmas = "beer "
let NewYear = "more beer"
main = putStrLn $ NewYear `after` Christmas

D:

string Christmas = "beer ";
string NewYear = "more beer";
if (Christmas ~ NewYear == "beer more beer")
  writeln("festive hangover");
over 1 year ago ·

IBM RPGIV

FXMASDF cf e workstn

D Christmas S 10 inz("beer")

D NewYear S 10 inz("more beer")

/free

if %trimR(Christmas) + %trimR(NewYear) = "beer more beer"

warning = ""festive hangover"

exfmt     message_rec

/end-free

over 1 year ago ·

Bash:

CHRISTMAS='beer '
NEW_YEAR='more beer'

if [[ $CHRISTMAS$NEW_YEAR='beer more beer' ]]; then
  echo 'festive hangover'
fi
over 1 year ago ·

Go:

package main

func main() {
  christmas := "beer "
  newYear := "more beer"
  if christmas+newYear == "beer more beer" {
    println("festive hangover")
  }
}

Tcl:

set christmas "beer "
set newYear "more beer"
if {"$christmas$newYear" == "beer more beer"} {
  puts "festive hangover"
}

(oh, also, please don't use === for equality in Ruby, it works in this case, but String === "beer more beer" would also be true. So can you change it to == instead? Pretty please :)

over 1 year ago ·

How can I use code syntax for actionscript ?

over 1 year ago ·

Perl

$Xmas= "beer ";
$NewYear = "more beer";
if ($Xmas.$NewYear eq "beer more beer") {
  print "festive hangover";}

Lua

christmas="beer "
newYear="more beer"
if christmas..newYear=="beer more beer" then
    print ("festive hangover")
end
over 1 year ago ·

Java

public static void main(String[] args) {
    String xmas = "beer ";
    String newYear = "more beer";

    if ((xmas + newYear).equals("beer more beer")) {
        System.out.println("festive hangover");
    }

}
over 1 year ago ·

Lisp


(let ((a "beer ")(b "more beer"))
 (if (string= (concatenate 'string a b) "beer more beer")
  (print "festive hangover")))
</code></pre>
over 1 year ago ·

@hauleth Did you perhaps mean ~? + doesn't do that in D...

over 1 year ago ·

Erlang:

-module(xmas).
-export([main/0]).

main() ->
    Xmas = "beer ",
    NewYear = "more beer",

    case Xmas ++ NewYear of
        "beer more beer" ->
            io:fwrite("festive hangover~n");
        _ ->
            ok
    end.

Erlang (recursive approach):

-module(xmas).
-export([main/0]).

drink(Beer="beer") ->
    drink([Beer|"more beer"]);

drink(["beer"|"more beer"]) ->
    io:fwrite("festive hangover~n").

main() ->
    drink("beer").
over 1 year ago ·

F#

let Christmas, NewYear = "beer ", "more beer"
if Christmas + NewYear = "beer more beer" then printfn "festive hangover"
over 1 year ago ·

Swift
let Christmas="beer "
let NewYear="more beer"

if Christmas+NewYear=="beer more beer" {
     println("festive hangover")
}
over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip