ruby - How to use method calls within rjust? -


As part of learning my Ruby, I call the size method within Pass it as the first parameter to make sure how to do it.

For example.

  2.to_s (2) # = & gt; Now, I would like to use  rjust  on  10  passing : size + 5  As  ***** 10  

  2.to_s (2) .rjust (how_to_get_size_of_10_and_add_5, "*") # = & amp; As the first argument to get; Do not know how  

failed, tried the following:

  2.to_s (2). Tap {| S | Strong (s.size + 5, "*")} # = & gt; ... Undefined method for main `rjust ': object 2.to_s (2) .just (send (: size) +5," * ") # = & gt; ... Undefined method for main `size ': object  

I am trying to understand the method of referencing and using a method on one part of a series of call methods. In my example, I am trying to call rjust on 2.to_s (2) and within the rjust size the Refer 2to_s (2) . Sorry, if I am written

I do not understand that you indirectly Why are you, but perhaps you have tried to do this:

  2.to_s (2) Tap {| S | Break s.rjust (s.size + 5, "*")}  

A new method is proposed for such situations in the Ruby Core, but it is not yet available In essence, you have to use a combination of tap and break .


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -