If it is Ruby, it is efficient to make it a method and stock the processing.


The other day, I noticed during an interview with a company. Perhaps it is a matter of course for engineers in the field, but it was quite a big notice for me who has no practical experience yet, so I hope that someone who sees this will also notice it. I hope to introduce it.

Keep frequently used code in stock

At this stage, I don't know what kind of code is often used, but in Ruby, you can make the process into a method, stock it, copy and paste it as needed, and call the method to finish the process. Feeled very efficient. As a point,

--Describe what you are doing in the comments. ――It feels like a return value is returned by making it a method and passing an argument. (For example, if you pass a number, it will be returned as a character string)

By the way, I wrote a new code every time I solved Paiza's problem, but I wrote the same thing many times ...


In response to this, a new question is

――What kind of processing is frequently used code? ――Is it the work of picking up what is rolling on the net without thinking for yourself in the first place?

about it. If you have any advice ...

Recommended Posts

If it is Ruby, it is efficient to make it a method and stock the processing.
Find a value that is convenient to have a method and make it a ValueObject
Program to determine if it is a leap year
[Ruby] I want to make an array from a character string with the split method. And vice versa.
When reassigning to an argument in a Ruby method and then calling `super` → The reassigned one is used
I want to call a method and count the number
If you want to make a Java application a Docker image, it is convenient to use jib.
[Ruby] present/blank method and postfix if.
Use Modifier # isStatic to determine if the [Reflection] method is static.
[Java] I tried to make a maze by the digging method ♪
How to identify the path that is easy to make a mistake
Easy to understand the difference between Ruby instance method and class method.
Resultset's next () is not a "method to determine if there is a ResultSet next".
If you want to mock a method in RSpec, you should use the allow method for mock and the singleton method.
Session was a cookie designed to be erased when the browser was closed and was a method for exchanging it: Rails Tutorial Note-What is a Rails Session?
[Ruby] What happens if the method self is used as the return value?
[Ruby] From the basics to the inject method
How to operate IGV using socket communication, and the story of making a Ruby Gem using that method
Memo: [Java] If a file is in the monitored directory, process it.
I want to download a file on the Internet using Ruby and save it locally (with caution)
JVM Performance Tuning: What is Tuning and How to Make a Good Plan
Get the type of an array element to determine if it is an array
Create a program to post to Slack with GO and make it a container
Iterative processing of Ruby using each method (find the sum from 1 to 10)
If you want to make a zip file with Ruby, it's rubyzip.
Resultset's next () was misunderstood as a method to determine if there is a next
Is it possible to put the library (aar) in the Android library (aar) and use it?
Since the image of the lock screen of Windows 10 is beautiful, I wanted to make it a slide show of wallpaper
If the parameter is an array, how to include it in Stopara's params.permit
A story when I tried to make a video by linking Processing and Resolume
How to check if an instance variable is defined in a Ruby class
[Ruby] How to calculate the total amount using the initialize method and class variables
[Ruby] What is the slice method? Let's solve the example and understand the difference from slice!
[Java] Is it unnecessary to check "identity" in the implementation of the equals () method?
A memorandum to clean up the code Ruby
Make a margin to the left of the TextField
[Ruby] How to use gsub method and sub method
Ruby sum is a sober and amazing story
[Ruby] I want to do a method jump!
[Ruby basics] How to use the slice method
[Ruby] How to use the map method. How to process the value of an object and get it by hash or symbol.
[Java] When putting a character string in the case of a switch statement, it is necessary to make it a constant expression
[Ruby] When you want to assign the result obtained by conditional branching to a variable and put it in the argument
[Swift] If the support of the application is iOS 11 or later, it was not necessary to use Int and Int64 properly
The patchForObject added to RestTemplate cannot be used effectively if it is a default implementation (the one that uses HttpURLConnection).
[Ruby] I want to make a program that displays today's day of the week!
[ruby] How to assign a value to a hash by referring to the value and key of another hash
Pass arguments to the method and receive the result of the operation as a return value
[Ruby] Get a 3-digit integer and conditionally branch using an if statement (digits method)
The end of catastrophic programming # 03 "Comparison of integers, if" a> b ", assume that it is" a --b> 0 ""
What to do if the breakpoint is shaded and does not stop during debugging
[Ruby] Cut out a string using the slice method
What is the difference between a class and a struct? ?? ??
If hash [: a] [: b] [: c] = 0 in Ruby, I want you to extend it recursively even if the key does not exist.
[Ruby] Method to easily get the receiver type .class
Bind the request to any class and receive it
Is it faster if the docker bind mount is readonly?
21 Load the script from a file and execute it
[Ruby] How to get the tens place and the ones place
How to make a mod for Slay the Spire
[Quarkus] A trap that doesn't work even if you copy and paste the GCP Pub / Sub sample as it is