irh2ya
Last Updated: February 25, 2016
·
5.61K
· anthonylevings
Speechrocket4 square

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

2697
3c4478e6ae6c60b73d21c9fa0d1785ea

C#:

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

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

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 ·
2728
20bf1894a08c885fee4d4cf5ad7a8e87

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 ·
2730
Avatar

Bash:

CHRISTMAS='beer '
NEW_YEAR='more beer'

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

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 ·
2784

How can I use code syntax for actionscript ?

over 1 year ago ·
2787

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 ·
2788
C14f52a4e945210255103282b90c3343

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 ·
2791

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 ·
2794
2

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

over 1 year ago ·
2847
00f1bf67a52fc75fb6da011edcf3f42b

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 ·
3685
E519e735596b76d539a193bfabff1d81

F#

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

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

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