ruby-standard-classes

ruby standard class in hindi

Standard Calsses

ruby की library में बहुत सी built-in classes हैं, जिस से ruby programming करना और भी आसान हो जाता है। चूँकि एक classes के method बहुत ही useful हैं। "Math" भी एक ऐसी ही class है जिस से mathematical operation करने और भी आसान हो जाते है।
  1. #Use math class
  2. #Square root
  3. puts Math.sqrt(9)
  4. #pi constant
  5. puts Math::PI

  6. #Outputs
  7. 3.0
  8. 3.141592653589793

"Time" Class

  1. #Using time class
  2. #current time
  3. puts "Current Time: #{time=Time.now}"
  4. #puts time
  5. #Year, Month, Day
  6. puts "Year: #{time.year}"
  7. puts "Month: #{time.month}"
  8. puts "Day; #{time.day}"
  9. #Custom
  10. puts "Custom Time: #{time=Time.new(1990,01,01)}"

  11. #Outputs
  12. Current Time: 2019-01-02 14:13:50 +0530
  13. Year: 2019
  14. Month: 1
  15. Day; 2
  16. Custom Time: 1990-01-01 00:00:00 +0530
Share on Google Plus

About Lakhvir Singh

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment