Chen Log

陳洛格

Ruby on Rails 字串連接方法

leave a comment »

PHP的連接是用點 “ . ”  如這樣:

$a=”500″;
$b=”apple”;

echo $a.$b;

// print: ” 500apple” 

而Java的話是採用 “+” 加號。

Ruby String字串與Value變數的的連接長的比較變態一點,
是這樣的:

$str = "#{@str1}ABCD#{@str2}CFDE"

 

沒錯!
就是引號內加上#{@變數} = “#{@變數} “

Advertisements

Written by chenagw

2013/01/11 at 13:46

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: