Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7301

Re: String Interpolation of Compound Statement

From "Robert L." <No_spamming@noWhere_7073.org>
Newsgroups comp.lang.ruby
Subject Re: String Interpolation of Compound Statement
Date 2016-11-24 22:08 +0000
Organization Aioe.org NNTP Server
Message-ID <o17odj$1pab$1@gioia.aioe.org> (permalink)
References <76ebf773-0dac-47e2-88e2-123260a6b309@googlegroups.com>

Show all headers | View raw


On 9/1/2016, BeeRich33 wrote:

> @f += "\t<label for=\"" + @h[("s_fieldname_" + i.to_s)].to_s +
>   "\">" + @fieldname.capitalize + ":"
> 
> Now I've been told there are less
> errors with string interpolation.  How
> can I translate that?

@fieldname = "foo"
i = 2
@h = {"s_fieldname_2" => 1984}

"\t<label for=\"" + @h[("s_fieldname_" + i.to_s)].to_s +
  "\">" + @fieldname.capitalize + ":"
    ==>"\t<label for=\"1984\">Foo:"

"\t<label for=\"#{@h[("s_fieldname_" + i.to_s)]}\">#{@fieldname.capitalize}:"
    ==>"\t<label for=\"1984\">Foo:"

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar


Thread

String Interpolation of Compound Statement BeeRich33 <beerich@gmail.com> - 2016-09-01 14:14 -0700
  Re: String Interpolation of Compound Statement "Robert L." <No_spamming@noWhere_7073.org> - 2016-11-24 22:08 +0000

csiph-web