layout | title |
---|---|
post |
时间旅行发生错误,你在冰封之地失去了方向 |
# This is Ruby
class ErrorReasoner
def initialize
@message_title = '404 Not Found'
@message_content = '你来到这个页面,通常有三个原因'
end
def my_attr_accessor(*args)
args.each do |i|
eval "p @#{i}"
end
end
def _print_reason
my_attr_accessor :message_title, :message_content
end
end
printer = ErrorReasoner.new
printer._print_reason
// This is Java
public class ErrorReasoner {
public ErrorReasoner() {
}
public final String messageTitle = "一、链接错误";
public final String messageContent =
"原因:博客搬迁造成的旧链接失效。请回到主页。(*′﹃`*)";
public void printMessage(String msg) {
System.out.println(msg);
}
public static void main(String[] args) {
ErrorReasoner reasoner = new ErrorReasoner();
reasoner.printMessage(messageTitle);
reasoner.printMessage(messageContent);
}
}
// This is Kotlin
class ErrorReasoner(private var printer: (message: String) -> Unit) {
fun printMessage(message: String): Unit
= printer(message)
}
fun main(args: Array<String>) {
var reasoner = ErrorReasoner { println(it) }
reasoner.printMessage("二、实验事故")
reasoner.printMessage(
"原因:冰封所建立的时间之域被隔壁实验室里的对撞机事故影响," +
"造成部分页面损伤。"
)
}
// This is C ( pure C )
#include <stdlib.h>
#include <string.h>
const char* echo = "echo ";
void printMessage(char* message) {
char* command = (char*) malloc (strlen(message) + strlen(echo) );
strcpy(command, echo);
strcpy(command + strlen(echo), message);
system(command);
}
int main(int argc, char* argv[]) {
printMessage("三、末日降临");
printMessage(
"原因:在归零者文明的号召下," +
"冰封已将建立好的独立时间之域回归主宇宙。别担心,数据已经备份。"
);
return 0;
}