Monday, February 29, 2016

Ruby warning message: (...) interpreted as grouped expression

While following along with a tutorial I was asked to write a short program that asked the user for a sentence and then a number.  After that was complete, type out the sentence backwards the number of times that was keyed in by the user. For example when typing in a string "ABCDEF GHI" three times, I would get something that looked like this...

IHG FEDCBA
IHG FEDCBA
IHG FEDCBA

Here's the code that I typed out at first which works but I did get a warning message within Aptana Studio...


print "Type any sentence: "
sent = gets.chomp
print "Type a whole number: "
num = gets.chomp.to_i

puts "here are your sentences backwards times the number you keyed in..."
puts (sent.reverse + "\n") * num

The warning message was... 

(...) interpreted as grouped expression

After doing a google search, I came across a post that read...

"...This warning is emitted when Ruby thinks that you want an argument list but wrote a grouped expression instead. The most common cause is whitespace between the name of the message and the argument list in a message..."

...which made a lot of sense.  I don't like warnings in anything I'm coding out so I changed the code on line 7 to read...


puts "#{sent.reverse}\n" * num

After the change was made, the warning in Aptana went away.

Thursday, February 25, 2016

Installing Aptana Studio 3

Updated for Ubuntu 16.04:
I'm one that likes intellisense/code completion and the benefits of an IDE and until I can make a living as a developer, I'm using a free tool that is available called Aptana Studio 3 onto a Ubuntu 16.04 vm image.

I'll be taking most of the steps on how to install from the WordPress tutorial. In order to make Aptana work with Ubuntu 16.04, I had to make some changes to the steps mentioned in the tutorial.

https://pratapsatve.wordpress.com/2015/05/20/install-aptana-studio-3-in-ubuntu-14-04/

1. Install the dependencies
sudo apt-get install openjdk-8-jdk nodejs libwebkitgtk-1.0-0

2. Download the appropriate Aptana file from the website...
http://www.aptana.com/products/studio3/download

3. I used FireFox to download the file so it ended up in the ~/Downloads folder. Open up the terminal and navigate to the folder that it downloaded into
unzip Aptana_Studio_3_Setup_Linux_x86_64_3.6.1.zip
(change the version number to match the version you downloaded)

4. Move the newly created folder to the /opt directory...
sudo mv Aptana_Studio_3 /opt

I don't like zip files just hanging out so I remove them after unzipping them.
rm Aptana_Studio_3_Setup_Linux_x86_64_3.6.1.zip

5. Have to create an app launcher for Aptana Studio by installing gnome-panel if you haven't already done so...
sudo apt-get install --no-install-recommends gnome-panel

6. Navigate to the /opt/Aptana_Studio_3 folder and type the following...
gnome-desktop-item-edit ~/Desktop/ --create-new

7. A Create Launcher window will open. Type in a name that you want to see to open up Aptana.  I typed Aptana Studio 3.6.1 so that I'll know what version I have. Click on the browse button which should open up right in the Aptana directory and select AptanaStudio3 file and click the Open button. Click on the icon button to select icon.xpm file and click the Open button. Finally click on the OK button and you should now have an Aptana icon on your desktop.

Almost all of the above steps did come from the WordPress site mentioned above. I decided to retype all of the steps in case that site does go away at any point.