in ,

Getting User Input

Basics

This is a bit on the basics of grabbing user input from a console, using Ruby, Python and Groovy.

Ruby:

The command to request user input in a console is: gets
More specifically, one should use gets.chomp
chomp removes the extra lines that might come in.

Example: user_name = gets.chomp

Python:

In Python3 the command to request user input from the console is: input()

Example: user_name = input(“What is your username?”)

Groovy:

Groovy uses this syntax:

def username = System.console().readLines(“What is your Username?”)

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by Admin

I work for a Telecom company writing and testing software. My passion for writing code is expressed through this blog. It's my hope that it gives hope to any and all who are self-taught.

Comments

Leave a Reply

Loading…

Python Pcap Parsing

Ruby: Using bangs to change assignments