• String Interpolation of Compound Statement

    From Robert L.@21:1/5 to All on Thu Nov 24 22:08:52 2016
    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:"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From BeeRich33@21:1/5 to All on Thu Sep 1 14:14:14 2016
    Hi folks. I come from a language where we don’t have string interpolation. Here’s what I would usually write:

    @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? I get hung up on the internal bit here:

    @h[("s_fieldname_" + i.to_s)

    I’m sure it’s out there. I appreciate any input.

    Cheers

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)