More Types Intelligence in RubyMine
In the previous article covering type inference we’ve reviewed the following cases:
- Type Inference for local variables
forindex variable type
But there’s more, much more…
Let’s see more intelligence RubyMine shows when editing Ruby code.
Unknown Method Calls
If in your code you make a method call or reference an attribute that RubyMine for some reason cannot resolve, you will be notified about it by the appropriate inspection but only once for this particular method and current variable. And your code will not look all red.
If you press Ctrl+B/⌘ B on such method call it will resolve to the first occurrence where inspection error is shown.
Custom Error Types
RubyMine correctly resolves your custom exceptions and their methods when you want to handle errors in your code.
class MyError err
Code completion shows the methods and attributes of custom error class
Block Variables Type
yield and blocks is one of the many things that make the Ruby language interesting. RubyMine understands that and can see the type of block variables used within block calls.
i = 0
while i <= count do
my_iterate(5) do |i|
puts(“Current: ” + i.to_s)
So code completion only shows the relevant items.
Guessing Return Type from Method Comment
For RubyMine even the comments you write in your code are important and it uses them to help you in your work. RubyMine can get the type of method return value from method comment and then use it for more precise code completion.
These are some of the basic code editing and code completion features that help being more productive.
Stay tuned for lots more like this. We’ll cover Ruby on Rails related features next time.
Subscribe to Blog updates
Thanks, we've got you!
RubyMine 2020.3.4 and 2021.1.1 introduce the concept of trusted projects. It is designed to reduce the risks associated with opening projects from unknown or untrusted sources. Check out this blog post to learn more. As you might already know, when you open a project, RubyMine runs various tools lik…
RubyMine Navigation: Recent Locations PopupEarly Access Program
RubyMine 2019.1 is filled with features and options to help you navigate around your projects quickly without a mouse or touchpad. For example, you can quickly switch between tool windows, go to classes or actions, and open recently edited files. In our Navigate in RubyMine Like a Pro blog post, we …
How to work with Docker/Docker Compose from RubyMineEarly Access Program
To get the most recent information about Docker support in RubyMine, refer to our documentation: Tutorial: Docker Compose as a remote interpreter Tutorial: Docker as a remote interpreter RubyMine 2019.1 has a bunch of capabilities which allow you to work with Docker and Docker Compose. You can i…
Profile Ruby & Rails Apps With rbspy in RubyMineEarly Access Program
RubyMine 2019.1 adds support for rbspy – a great sampling profiler for Ruby (many thanks to @jvns!). This post will help you start profiling your Ruby/Rails apps with RubyMine in 5 minutes. Here are the exact steps: Identify the scenario to be analyzed Create a profiler configuration Run…